{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# coding=utf-8\n",
    "# --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   Unnamed: 0    ts_code  code  name area industry  list_date  liutongliang\n",
      "0           0  000001.SZ     1  平安银行   深圳       银行   19910403  1.940575e+06\n",
      "1           1  000002.SZ     2   万科A   深圳     全国地产   19910129  9.714315e+05 100\n",
      "['000001', '000002', '000004']\n",
      "用时 0:00:00.003997\n",
      "000001 东方财富人气榜  · 平安银行即时排名第 322 名\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-42:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-37-e3b43810975e>\", line 27, in test2\n",
      "    browser.get(mainUrl)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 333, in get\n",
      "    self.execute(Command.GET, {'url': url})\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 321, in execute\n",
      "    self.error_handler.check_response(response)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 242, in check_response\n",
      "    raise exception_class(message, screen, stacktrace)\n",
      "selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import threading\n",
    "import pandas as pd\n",
    "import time\n",
    "from datetime import datetime, date,timedelta\n",
    "from selenium import webdriver\n",
    "from selenium.webdriver.common.by import By\n",
    "from selenium.webdriver.support.ui import WebDriverWait\n",
    "from selenium.webdriver.support import expected_conditions as EC\n",
    "from selenium.webdriver.common.action_chains import ActionChains\n",
    "from selenium.webdriver.common.keys import Keys\n",
    "# def test(list_a):\n",
    "#     for i in list_a:\n",
    "#         browser = webdriver.Chrome()\n",
    "#         mainUrl = \"http://guba.eastmoney.com/list,{}.html\".format(i)\n",
    "#         browser.get(mainUrl)\n",
    "#         #print(f\"browser text = {browser.page_source}\")\n",
    "#         element = browser.find_element_by_id('popularity_rank')\n",
    "#         print(i,element.text)\n",
    "#         list_a.append(element.text)\n",
    "#         browser.close()\n",
    "#         time.sleep(1)\n",
    "def test2(list_b,browser):\n",
    "\n",
    "    for code in list_b:\n",
    "\n",
    "        mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "        browser.get(mainUrl)\n",
    "        element = browser.find_element_by_id('ad_rank')\n",
    "        print(code,element.text)\n",
    "        list_b.append([code,element])\n",
    "        browser.close()\n",
    "        time.sleep(1)\n",
    "\n",
    "# list_a=[\"000001\",\"000002\",\"000003\",\"000004\"]\n",
    "# list_b=[\"300001\",\"300002\",\"300003\",\"300004\"]\n",
    "# thread = threading.Thread(target=test,args=(list_a,))\n",
    "# thread.start()\n",
    "\n",
    "browser = webdriver.Chrome()\n",
    "browser.set_page_load_timeout(20)\n",
    "csv_data=pd.read_csv(\"x.txt\")[:100]\n",
    "print(csv_data[:2],len(csv_data))\n",
    "\n",
    "csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "list_code=csv_data[:3].code.tolist()\n",
    "print(list_code)\n",
    "list_b=[]\n",
    "date_start_1=datetime.now()\n",
    "thread = threading.Thread(target=test2,args=(list_code,browser))\n",
    "thread.start()\n",
    "\n",
    "date_end_1=datetime.now()\n",
    "print(\"用时\",(date_end_1-date_start_1))  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from queue import Queue\n",
    "import threading\n",
    "import time\n",
    "import json\n",
    "class ThreadCrawl(threading.Thread):\n",
    "    def __init__(self,threadName,pageQueue,dataQueue):\n",
    "#         threading.Thread\n",
    "        super(ThreadCrawl,self).__init__()\n",
    "    #线程名\n",
    "        self.threadName=threadName\n",
    "        self.pageQueue=pageQueue\n",
    "        self.dataQueue=dataQueue\n",
    "    def run(self):\n",
    "        while True:\n",
    "            try:\n",
    "                page=self.pageQueue.get(False)\n",
    "                mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "                browser.get(mainUrl)\n",
    "                element = browser.find_element_by_id('ad_rank')\n",
    "            except:\n",
    "                pass\n",
    "    \n",
    "    \n",
    "def main():\n",
    "    #队列10\n",
    "    pageQueue=Queue(10)\n",
    "    for i in range(1,11):\n",
    "        pageQueue.put(i)\n",
    "    #采集结果（每一页的数据队列，参数为空表示不限制）\n",
    "    dataQueue=Queue()\n",
    "    #线程名字\n",
    "    crawlList=[\"采集1\",\"采集2\",\"采集3\",\"采集4\"]\n",
    "    #存储3个线程\n",
    "    threadcrawl=[]\n",
    "    for threadName in crawlList:\n",
    "        thread=ThreadCrawl(threadName,pageQueue,dataQueue)\n",
    "        thread.start()\n",
    "        threadcrawl.append(thread)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TestThread test MainThread main   00\n",
      "\n",
      "TestThread is alive  True\n",
      "TestThread test  1\n",
      "MainThread main  1\n",
      "TestThread is alive  True\n",
      "TestThread test  2\n",
      "TestThread test  3\n",
      "MainThread main  2\n",
      "TestThread is alive  True\n",
      "TestThread test  4\n",
      "MainThread main  3\n",
      "TestThread is alive  False\n",
      "MainThread main  4\n",
      "TestThread is alive  False\n"
     ]
    }
   ],
   "source": [
    "import threading\n",
    "import time\n",
    "\n",
    "def test():\n",
    "\n",
    "    for i in range(5):\n",
    "        print(threading.current_thread().name+' test ',i)\n",
    "        time.sleep(0.5)\n",
    "\n",
    "\n",
    "thread = threading.Thread(target=test,name='TestThread')\n",
    "# thread = threading.Thread(target=test)\n",
    "thread.start()\n",
    "\n",
    "for i in range(5):\n",
    "    print(threading.current_thread().name+' main ', i)\n",
    "    print(thread.name+' is alive ', thread.isAlive())\n",
    "    time.sleep(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i was listening to 爱情买卖！ Tue Nov 24 21:50:52 2020\n",
      "i was at to 阿凡达！ Tue Nov 24 21:50:52 2020\n",
      "i was listening to 爱情买卖！ Tue Nov 24 21:50:54 2020\n",
      "i was at to 阿凡达！ Tue Nov 24 21:50:57 2020\n",
      "all end: Tue Nov 24 21:51:02 2020\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from time import sleep,ctime\n",
    "\n",
    "import threading\n",
    "\n",
    " \n",
    "\n",
    "def music(func,loop):\n",
    "\n",
    "\tfor i in range (loop):\n",
    "\n",
    "\t\tprint(\"i was listening to %s！ %s\" % (func,ctime()))\n",
    "\n",
    "\t\tsleep(2)\n",
    "\n",
    " \n",
    "\n",
    "def movie(func,loop):\n",
    "\n",
    "\tfor i in range (loop):\n",
    "\n",
    "\t\tprint(\"i was at to %s！ %s\" % (func,ctime()))\n",
    "\n",
    "\t\tsleep(5)\n",
    "\n",
    " \n",
    "\n",
    "threads=[]\n",
    "\n",
    " \n",
    "\n",
    "t1=threading.Thread(target=music,args=('爱情买卖',2))\n",
    "\n",
    "threads.append(t1)\n",
    "\n",
    " \n",
    "\n",
    "t2=threading.Thread(target=movie,args=('阿凡达',2))\n",
    "\n",
    "threads.append(t2)\n",
    "\n",
    " \n",
    "\n",
    "if __name__=='__main__':\n",
    "\n",
    "\tfor t in threads:\n",
    "\n",
    "\t\tt.start()\n",
    "\n",
    " \n",
    "\n",
    "\tfor t in threads:\n",
    "\n",
    "\t\tt.join()\n",
    "\n",
    " \n",
    "\n",
    "\tprint('all end: %s' % ctime())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "POST /stockrank/getHisList HTTP/1.1\n",
    "Host: emappdata.eastmoney.com\n",
    "Connection: keep-alive\n",
    "Content-Length: 88\n",
    "Accept: application/json, text/javascript, */*; q=0.01\n",
    "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36\n",
    "Content-Type: application/json\n",
    "Origin: https://vipmoney.eastmoney.com\n",
    "Sec-Fetch-Site: same-site\n",
    "Sec-Fetch-Mode: cors\n",
    "Sec-Fetch-Dest: empty\n",
    "Referer: https://vipmoney.eastmoney.com/\n",
    "Accept-Encoding: gzip, deflate, br\n",
    "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "POST /stockrank/getHisList HTTP/1.1\n",
    "Host: emappdata.eastmoney.com\n",
    "Connection: keep-alive\n",
    "Content-Length: 88\n",
    "Accept: application/json, text/javascript, */*; q=0.01\n",
    "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36\n",
    "Content-Type: application/json\n",
    "Origin: https://vipmoney.eastmoney.com\n",
    "Sec-Fetch-Site: same-site\n",
    "Sec-Fetch-Mode: cors\n",
    "Sec-Fetch-Dest: empty\n",
    "Referer: https://vipmoney.eastmoney.com/\n",
    "Accept-Encoding: gzip, deflate, br\n",
    "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8\n",
    "https://emappdata.eastmoney.com/stockrank/getHisList"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总用时： 0.0010004043579101562\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-6:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "TypeError: process() missing 1 required positional argument: 'num'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "from datetime import datetime, date,timedelta\n",
    "from selenium import webdriver\n",
    "from selenium.webdriver.common.by import By\n",
    "from selenium.webdriver.support.ui import WebDriverWait\n",
    "from selenium.webdriver.support import expected_conditions as EC\n",
    "from selenium.webdriver.common.action_chains import ActionChains\n",
    "from selenium.webdriver.common.keys import Keys\n",
    "import numpy as np\n",
    "import re\n",
    "import pandas as pd\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "\n",
    "def process(start,end,num):\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.set_page_load_timeout(20)\n",
    "    mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "    browser.get(mainUrl)\n",
    "    element = browser.find_element_by_id('ad_rank')\n",
    "    print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "    #000001 311 [nan] 102\n",
    "      # if(j%10==0):#每处理10页数据，关闭并重启一次浏览器\n",
    "      #     browser.quit()\n",
    "      #     browser = webdriver.Chrome(executable_path=driver_path)\n",
    "\n",
    "\n",
    "def main():\n",
    "\t #开启4个进程，传入爬取的页码范围\n",
    "    thead_list = []\n",
    "    a=[\"300001\",\"300002\",\"300003\",\"300004\"]\n",
    "    t1 = Thread(target=process, args=(a,1))\n",
    "    t1.start()\n",
    "#     thead_list.append(t1)\n",
    "\n",
    "    for t in thead_list:\n",
    "        t.join()\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    s = time.time()\n",
    "    main()\n",
    "    e = time.time()\n",
    "    print('总用时：',e-s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总用时： 0.0049970149993896484\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-27:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "TypeError: process() takes 1 positional argument but 2 were given\n",
      "\n",
      "Exception in thread Thread-28:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "TypeError: process() takes 1 positional argument but 3 were given\n",
      "\n"
     ]
    }
   ],
   "source": [
    " # --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "\n",
    "def process(a):\n",
    "#     driver_path = r\"D:\\chromedriver.exe\"\n",
    "    #使用开发者模式\n",
    "    #options = webdriver.ChromeOptions()\n",
    "    #options.add_experimental_option('excludeSwitches', ['enable-automation'])\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.implicitly_wait(1)\n",
    "\n",
    "\n",
    "#     count=1\n",
    "#     for j in range(start,end):\n",
    "#         if(count%21==0):\n",
    "#             count=1\n",
    "#         if(j==1):\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index.html\"\n",
    "#         else:\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index_\"+str(j-1)+\".html\"\n",
    "#         if(j%10==0):#每处理10页数据，关闭并重启一次浏览器\n",
    "#             browser.quit()\n",
    "#             browser = webdriver.Chrome()\n",
    "\n",
    "#     for i in range(20):\n",
    "#         browser.get(url)\n",
    "#         browser.maximize_window()\n",
    "#         print(\"####################################################第\",j,\"页，第\",count,\"条记录\")\n",
    "#         # 获取列表页handle\n",
    "#         list_page_handle = browser.current_window_handle\n",
    "#         div_content = browser.find_element_by_css_selector('div.g-content-list')\n",
    "#         li_list = div_content.find_elements_by_tag_name('li')\n",
    "#         a_href = li_list[i].find_element_by_tag_name('a').get_attribute('href')\n",
    "#         if(a_href.find('.pdf')>0 or a_href.find('.doc')>0 or a_href.find('.DOC')>0):continue\n",
    "#         print(a_href)\n",
    "#         li_list[i].find_element_by_tag_name('a').click()\n",
    "#         all_handles = browser.window_handles\n",
    "#         for handle in all_handles:\n",
    "#             if (handle != list_page_handle):\n",
    "#                 browser.switch_to.window(handle)\n",
    "#         #标题\n",
    "#         title_div = browser.find_element_by_css_selector('div.des-header')\n",
    "#         title_h2 = title_div.find_element_by_tag_name('h2')\n",
    "#         print(title_h2.text)\n",
    "#         data_row_title = [title_h2.text]\n",
    "#         with open('./data/sz_data_title' + str(num) + '.csv', 'a+', newline=\"\", encoding='utf-8') as f:\n",
    "#             csv_add = csv.writer(f)\n",
    "#             csv_add.writerow(data_row_title)\n",
    "#         #公告内容\n",
    "#         content_div = browser.find_element_by_id('desContent')\n",
    "#         p_content_list = content_div.find_elements_by_tag_name('p')\n",
    "#         final_text=\"\"\n",
    "#         for p in p_content_list:\n",
    "#             final_text+=p.text.strip()\n",
    "#         print(final_text)\n",
    "#         data_row = [final_text]\n",
    "#         with open('./data/sz_data'+ str(num) +'.csv', 'a+', newline=\"\",encoding='utf-8') as f:\n",
    "#             csv_add = csv.writer(f)\n",
    "#             csv_add.writerow(data_row)\n",
    "#         time.sleep(1)\n",
    "#         count += 1\n",
    "#         browser.close()\n",
    "#         browser.switch_to.window(list_page_handle)\n",
    "\n",
    "def main():\n",
    "\t #开启4个进程，传入爬取的页码范围\n",
    "    a=[\"300001\",\"300002\",\"300003\",\"300004\"]\n",
    "    thead_list = []\n",
    "    t1 = Thread(target=process, args=(a,1))\n",
    "    t1.start()\n",
    "    t2 = Thread(target=process, args=(600, 800,1))\n",
    "    t2.start()\n",
    "    thead_list.append(t1)\n",
    "    thead_list.append(t2)\n",
    "    for t in thead_list:\n",
    "        t.join()\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    s = time.time()\n",
    "    main()\n",
    "    e = time.time()\n",
    "    print('总用时：',e-s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'threads'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-16-9970c23fd4c2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mthreads\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'threads'"
     ]
    }
   ],
   "source": [
    "import threads"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'threads' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-15-993801c756ac>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mthreads\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'threads' is not defined"
     ]
    }
   ],
   "source": [
    "dir(threads)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The following command must be run outside of the IPython shell:\n",
      "\n",
      "    $ pip install threads\n",
      "\n",
      "The Python package manager (pip) can only be used from outside of IPython.\n",
      "Please reissue the `pip` command in a separate terminal or command prompt.\n",
      "\n",
      "See the Python documentation for more informations on how to install packages:\n",
      "\n",
      "    https://docs.python.org/3/installing/\n"
     ]
    }
   ],
   "source": [
    "pip install threads"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from time import ctime, sleep\n",
    "\n",
    "from selenium import webdriver\n",
    "\n",
    "import threading\n",
    "\n",
    " \n",
    "\n",
    "def select_browser(browser):\n",
    "\n",
    "    print(\"start %s\" % browser, ctime())\n",
    "\n",
    "    try:\n",
    "\n",
    "        if browser == 'Chrome' or browser == \"Ch\":\n",
    "\n",
    "            dr = webdriver.Chrome()\n",
    "\n",
    "        elif browser == 'Firefox' or browser == 'Ff':\n",
    "\n",
    "            dr = webdriver.Firefox()\n",
    "\n",
    "        elif browser == 'Ie' or browser == 'ie':\n",
    "\n",
    "            dr = webdriver.Ie()\n",
    "\n",
    "        elif browser == 'phantomjs' or browser == 'PhantomJS':\n",
    "\n",
    "            dr = webdriver.PhantomJS()\n",
    "\n",
    "        else:\n",
    "\n",
    "            print(\"Not found %s browser,You can use ‘firefox‘, ‘chrome‘, ‘ie‘ or ‘phantomjs‘\"% browser)\n",
    "\n",
    "        return dr\n",
    "\n",
    "    except Exception as msg:\n",
    "\n",
    "        print(\"启动浏览器出现异常：%s\" % str(msg))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def test_baidu(browser_name):\n",
    "\n",
    "    driver = select_browser(browser_name)\n",
    "\n",
    "    driver.maximize_window()\n",
    "\n",
    "    driver.get(\"https://www.baidu.com\")\n",
    "\n",
    "    driver.find_element_by_id('kw').send_keys('selenium')\n",
    "\n",
    "    driver.find_element_by_id('su').click()\n",
    "\n",
    "    sleep(2)\n",
    "\n",
    "    print(driver.title)\n",
    "\n",
    "    driver.quit()\n",
    "\n",
    "    print(\"end %s\" % browser_name, ctime())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start Chrome Wed Nov 25 22:18:24 2020\n",
      "selenium_百度搜索\n",
      "end Chromeend all time Wed Nov 25 22:18:38 2020 \n",
      "Wed Nov 25 22:18:38 2020\n"
     ]
    }
   ],
   "source": [
    "def thread_browser(*args):\n",
    "\n",
    "    if args:\n",
    "\n",
    "        threads = []                     # 创建线程列表\n",
    "\n",
    "        for browser in args:\n",
    "\n",
    "            t = threading.Thread(target=test_baidu, args=(browser,))    # 创建线程\n",
    "\n",
    "            threads.append(t)\n",
    "\n",
    "        for t in threads:\n",
    "\n",
    "            t.start()                    # 启动线程\n",
    "\n",
    "        for t in threads:\n",
    "\n",
    "            t.join()                     # 守护线程\n",
    "\n",
    "        print(\"end all time %s\"% ctime())\n",
    "\n",
    "    else:\n",
    "\n",
    "        print(\"Please pass at least one browser name\")\n",
    "\n",
    " \n",
    "\n",
    " \n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "\n",
    "    thread_browser('Chrome')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 50 entries, 0 to 49\n",
      "Data columns (total 11 columns):\n",
      "code            50 non-null object\n",
      "和昨天比例           50 non-null float64\n",
      "和MA120比例        50 non-null float64\n",
      "运行time          50 non-null object\n",
      "fc时间            50 non-null int64\n",
      "x1<35%          50 non-null float64\n",
      "实时价格            50 non-null float64\n",
      "zk              50 non-null float64\n",
      "zd              50 non-null float64\n",
      "dxw             14 non-null object\n",
      "renqipaiming    50 non-null int64\n",
      "dtypes: float64(6), int64(2), object(3)\n",
      "memory usage: 4.7+ KB\n",
      "None\n",
      "300619 281 [nan] 702 True\n",
      "600206 730 [nan] 692 False\n",
      "--------------------------text2 300506\n",
      "--------------------------text2 300698\n",
      "--------------------------text2 600838\n",
      "--------------------------text2 300634\n",
      "--------------------------text2 300460\n",
      "--------------------------text2 000016\n",
      "--------------------------text2 002402\n",
      "--------------------------text2 600744\n",
      "--------------------------text2 600726\n",
      "--------------------------text2 300733\n",
      "603618 2983 [nan] 2608 False\n",
      "600268 1584 ['游资'] 2203 True\n",
      "300419 426 [nan] 475 True\n",
      "600868 928 [nan] 1770 True\n",
      "600995 1490 [nan] 2034 True\n",
      "002386 2245 [nan] 1151 False\n",
      "300025 3032 [nan] 1498 False\n",
      "002156 204 [nan] 351 True\n",
      "300506 2409 [nan] 1668 False\n",
      "300698 3416 ['游资'] 1432 False\n",
      "600838 3009 [nan] 2427 False\n",
      "--------------------------text2 300506\n",
      "--------------------------text2 300698\n",
      "--------------------------text2 600838\n",
      "--------------------------text2 300634\n",
      "--------------------------text2 300460\n",
      "--------------------------text2 000016\n",
      "--------------------------text2 002402\n",
      "--------------------------text2 600744\n",
      "--------------------------text2 600726\n",
      "--------------------------text2 300733\n",
      "300634 2847 ['游资'] 2120 False\n",
      "300460 1449 [nan] 1063 False\n",
      "000016 716 [nan] 748 True\n",
      "002402 963 ['机构'] 938 False\n",
      "600744 256 [nan] 925 True\n",
      "600726 1016 ['游资'] 2073 True\n",
      "300733 972 [nan] 2479 True\n",
      "300001 519 [nan] 259 False\n",
      "603679 1573 [nan] 3507 True\n",
      "--------------------------text2 300506\n",
      "--------------------------text2 300698\n",
      "--------------------------text2 600838\n",
      "--------------------------text2 300634\n",
      "--------------------------text2 300460\n",
      "--------------------------text2 000016\n",
      "--------------------------text2 002402\n",
      "--------------------------text2 600744\n",
      "--------------------------text2 600726\n",
      "--------------------------text2 300733\n",
      "002232 1526 ['游资'] 783 False\n",
      "603700 2520 [nan] 1613 False\n",
      "002531 421 ['机构'] 899 True\n",
      "000591 364 [nan] 442 True\n",
      "002463 509 [nan] 478 False\n",
      "603232 2601 [nan] 647 False\n",
      "300234 3087 [nan] 2900 False\n",
      "300202 1797 ['游资'] 2073 True\n",
      "603330 2786 [nan] 3111 True\n",
      "000564 722 ['游资'] 858 True\n",
      "603915 2102 ['游资'] 1463 False\n",
      "--------------------------text2 300506\n",
      "--------------------------text2 300698\n",
      "--------------------------text2 600838\n",
      "--------------------------text2 300634\n",
      "--------------------------text2 300460\n",
      "--------------------------text2 000016\n",
      "--------------------------text2 002402\n",
      "--------------------------text2 600744\n",
      "--------------------------text2 600726\n",
      "--------------------------text2 300733\n",
      "300113 1676 ['机构'] 1534 False\n",
      "600318 1456 ['游资'] 123 False\n",
      "002288 70 [nan] 1182 True\n",
      "300105 2967 [nan] 3553 True\n",
      "600292 3582 [nan] 3797 True\n",
      "600396 1029 ['游资'] 2112 True\n",
      "300094 247 [nan] 2888 True\n",
      "300108 1644 [nan] 700 False\n",
      "300065 990 ['机构'] 2514 True\n",
      "300366 2325 [nan] 2708 True\n",
      "000700 1378 [nan] 934 False\n",
      "--------------------------text2 300506\n",
      "--------------------------text2 300698\n",
      "--------------------------text2 600838\n",
      "--------------------------text2 300634\n",
      "--------------------------text2 300460\n",
      "--------------------------text2 000016\n",
      "--------------------------text2 002402\n",
      "--------------------------text2 600744\n",
      "--------------------------text2 600726\n",
      "--------------------------text2 300733\n",
      "000613 2397 [nan] 3349 True\n",
      "002660 2513 [nan] 1910 False\n",
      "300527 1356 [nan] 1119 False\n",
      "600131 1230 [nan] 2316 True\n",
      "300342 1854 [nan] 1260 False\n",
      "300364 712 [nan] 926 True\n",
      "总用时： 122.65559506416321\n"
     ]
    }
   ],
   "source": [
    "# coding=utf-8\n",
    "# --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "import pandas as pd\n",
    "import re\n",
    "def process(code_list,csv_data,num):\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.set_page_load_timeout(20)\n",
    "    for code in code_list:\n",
    "\n",
    "        mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "        browser.get(mainUrl)\n",
    "        element = browser.find_element_by_id('ad_rank')\n",
    "        #print(\"text1\",mainUrl,element.text)\n",
    "        print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "    browser.quit()\n",
    "def process2(code_list,num):\n",
    "    for i in code_list:\n",
    "        print(\"--------------------------text2\",i)\n",
    "    #使用开发者模式\n",
    "    #options = webdriver.ChromeOptions()\n",
    "#     #options.add_experimental_option('excludeSwitches', ['enable-automation'])\n",
    "#     browser = webdriver.Chrome()\n",
    "#     browser.implicitly_wait(10)\n",
    "\n",
    "\n",
    "#     count=1\n",
    "#     for j in range(start,end):\n",
    "#         if(count%21==0):\n",
    "#             count=1\n",
    "#         if(j==1):\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index.html\"\n",
    "#         else:\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index_\"+str(j-1)+\".html\"\n",
    "#         if(j%10==0):#每处理10页数据，关闭并重启一次浏览器\n",
    "#             browser.quit()\n",
    "#             browser = webdriver.Chrome()\n",
    "\n",
    "\n",
    "def data_get():\n",
    "        #数据读取并改变\n",
    "    csv_data=pd.read_csv(\"x.txt\")\n",
    "    csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "    csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "\n",
    "    df_shujuxiazai=pd.read_csv(\"dxw.txt\")\n",
    "    df_shujuxiazai=df_shujuxiazai.loc[:, ~df_shujuxiazai.columns.str.contains('^Unnamed')].drop_duplicates() #2去掉Unnamed 并且去重\n",
    "    df_shujuxiazai['code']=df_shujuxiazai['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_shujuxiazai[[\"code\",\"dxw\"]],how=\"left\")\n",
    "\n",
    "    df_rq=pd.read_csv(\"renqicsv2txt.txt\")\n",
    "    df_rq['code']=df_rq['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_rq[[\"code\",\"renqipaiming\"]],how='inner',on='code')  \n",
    "    print(csv_data.info())\n",
    "    return csv_data\n",
    "\n",
    "def main():\n",
    "\t #开启4个进程，传入爬取的页码范围\n",
    "    thead_list = []\n",
    "    csv_data=data_get()\n",
    "\n",
    "    #选取\n",
    "    csv_li=csv_data.code.tolist()\n",
    "    for i in range(int(len(csv_li)/10)):\n",
    "    #     print(csv_li[10*i:10*(i+1)])\n",
    "        t1 = Thread(target=process, args=(csv_li[10*i:10*(i+1)],csv_data,1))\n",
    "        t1.start()\n",
    "        time.sleep(10) \n",
    "        t2 = Thread(target=process2, args=(csv_data.code[10:20],1))\n",
    "        t2.start()\n",
    "\n",
    "        thead_list.append(t1)\n",
    "        thead_list.append(t2)\n",
    "\n",
    "        for t in thead_list:\n",
    "            t.join()\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    s = time.time()\n",
    "    main()\n",
    "    e = time.time()\n",
    "    print('总用时：',e-s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# coding=utf-8\n",
    "# --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "import pandas as pd\n",
    "import re\n",
    "# def process(code_list,csv_data,num):\n",
    "#     browser = webdriver.Chrome()\n",
    "#     browser.set_page_load_timeout(20)\n",
    "#     for code in code_list:\n",
    "\n",
    "#         mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "#         browser.get(mainUrl)\n",
    "#         element = browser.find_element_by_id('ad_rank')\n",
    "#         #print(\"text1\",mainUrl,element.text)\n",
    "#         print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "#     browser.quit()\n",
    "# def process2(code_list,num):\n",
    "#     for i in code_list:\n",
    "#         print(\"--------------------------text2\",i)\n",
    "    #使用开发者模式\n",
    "    #options = webdriver.ChromeOptions()\n",
    "#     #options.add_experimental_option('excludeSwitches', ['enable-automation'])\n",
    "#     browser = webdriver.Chrome()\n",
    "#     browser.implicitly_wait(10)\n",
    "\n",
    "\n",
    "#     count=1\n",
    "#     for j in range(start,end):\n",
    "#         if(count%21==0):\n",
    "#             count=1\n",
    "#         if(j==1):\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index.html\"\n",
    "#         else:\n",
    "#             url=\"http://www.szse.cn/disclosure/notice/index_\"+str(j-1)+\".html\"\n",
    "#         if(j%10==0):#每处理10页数据，关闭并重启一次浏览器\n",
    "#             browser.quit()\n",
    "#             browser = webdriver.Chrome()\n",
    "\n",
    "\n",
    "def data_get():\n",
    "        #数据读取并改变\n",
    "    csv_data=pd.read_csv(\"x.txt\")\n",
    "    csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "    csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "\n",
    "    df_shujuxiazai=pd.read_csv(\"dxw.txt\")\n",
    "    df_shujuxiazai=df_shujuxiazai.loc[:, ~df_shujuxiazai.columns.str.contains('^Unnamed')].drop_duplicates() #2去掉Unnamed 并且去重\n",
    "    df_shujuxiazai['code']=df_shujuxiazai['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_shujuxiazai[[\"code\",\"dxw\"]],how=\"left\")\n",
    "\n",
    "    df_rq=pd.read_csv(\"renqicsv2txt.txt\")\n",
    "    df_rq['code']=df_rq['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_rq[[\"code\",\"renqipaiming\"]],how='inner',on='code')  \n",
    "    print(csv_data.info())\n",
    "    return csv_data\n",
    "\n",
    "def main():\n",
    "\t #开启4个进程，传入爬取的页码范围\n",
    "    thead_list = []\n",
    "    #csv_data=data_get()\n",
    "\n",
    "    #选取\n",
    "    list_=[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\"]\n",
    "    for i in list_:\n",
    "        t1 = Thread(target=process, args=(csv_data.code.tolist()[:10],1))\n",
    "        t1.start()\n",
    "\n",
    "\n",
    "\n",
    "    thead_list.append(t1)\n",
    "\n",
    "\n",
    "    for t in thead_list:\n",
    "        t.join()\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    s = time.time()\n",
    "    main()\n",
    "    e = time.time()\n",
    "    print('总用时：',e-s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 50 entries, 0 to 49\n",
      "Data columns (total 11 columns):\n",
      "code            50 non-null object\n",
      "和昨天比例           50 non-null float64\n",
      "和MA120比例        50 non-null float64\n",
      "运行time          50 non-null object\n",
      "fc时间            50 non-null int64\n",
      "x1<3.5%         50 non-null float64\n",
      "实时价格            50 non-null float64\n",
      "zk              50 non-null float64\n",
      "zd              50 non-null float64\n",
      "dxw             14 non-null object\n",
      "renqipaiming    50 non-null int64\n",
      "dtypes: float64(6), int64(2), object(3)\n",
      "memory usage: 4.7+ KB\n",
      "None\n",
      "600868 478 [nan] 1770 True\n",
      "300619 394 [nan] 702 True\n",
      "600995 947 [nan] 2034 True\n",
      "300506 1126 [nan] 1668 True\n",
      "600206 71 [nan] 692 True\n",
      "300698 1321 ['游资'] 1432 True\n",
      "002386 931 [nan] 1151 True\n",
      "603618 809 [nan] 2608 True\n",
      "600838 515 [nan] 2427 True\n",
      "000016 296 [nan] 748 True\n",
      "300025 777 [nan] 1498 True\n",
      "600268 151 ['游资'] 2203 True\n",
      "300634 452 ['游资'] 2120 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-84:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-13-25e052a742d1>\", line 14, in process\n",
      "    element = browser.find_element_by_id('ad_rank')\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 360, in find_element_by_id\n",
      "    return self.find_element(by=By.ID, value=id_)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 978, in find_element\n",
      "    'value': value})['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 321, in execute\n",
      "    self.error_handler.check_response(response)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 242, in check_response\n",
      "    raise exception_class(message, screen, stacktrace)\n",
      "selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed\n",
      "from unknown error: web view not found\n",
      "  (Session info: chrome=87.0.4280.66)\n",
      "\n",
      "\n",
      "Exception in thread Thread-83:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-13-25e052a742d1>\", line 14, in process\n",
      "    element = browser.find_element_by_id('ad_rank')\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 360, in find_element_by_id\n",
      "    return self.find_element(by=By.ID, value=id_)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 978, in find_element\n",
      "    'value': value})['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 321, in execute\n",
      "    self.error_handler.check_response(response)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 242, in check_response\n",
      "    raise exception_class(message, screen, stacktrace)\n",
      "selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed\n",
      "from unknown error: web view not found\n",
      "  (Session info: chrome=87.0.4280.66)\n",
      "\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "002156 75 [nan] 351 True\n",
      "300419 162 [nan] 475 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-82:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-13-25e052a742d1>\", line 14, in process\n",
      "    element = browser.find_element_by_id('ad_rank')\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 360, in find_element_by_id\n",
      "    return self.find_element(by=By.ID, value=id_)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 978, in find_element\n",
      "    'value': value})['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 321, in execute\n",
      "    self.error_handler.check_response(response)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 242, in check_response\n",
      "    raise exception_class(message, screen, stacktrace)\n",
      "selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed\n",
      "from unknown error: web view not found\n",
      "  (Session info: chrome=87.0.4280.66)\n",
      "\n",
      "\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-25e052a742d1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     39\u001b[0m     \u001b[0mt1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mThread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mprocess\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mcsv_data\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     40\u001b[0m     \u001b[0mt1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstart\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 41\u001b[1;33m     \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-85:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-13-25e052a742d1>\", line 8, in process\n",
      "    browser = webdriver.Chrome()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py\", line 81, in __init__\n",
      "    desired_capabilities=desired_capabilities)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 157, in __init__\n",
      "    self.start_session(capabilities, browser_profile)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 252, in start_session\n",
      "    response = self.execute(Command.NEW_SESSION, parameters)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 321, in execute\n",
      "    self.error_handler.check_response(response)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 242, in check_response\n",
      "    raise exception_class(message, screen, stacktrace)\n",
      "selenium.common.exceptions.SessionNotCreatedException: Message: session not created\n",
      "from chrome not reachable\n",
      "  (Session info: chrome=87.0.4280.66)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "import pandas as pd\n",
    "import re\n",
    "def process(code_list,csv_data,num):\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.set_page_load_timeout(20)\n",
    "    for code in code_list:\n",
    "\n",
    "        mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "        browser.get(mainUrl)\n",
    "        element = browser.find_element_by_id('ad_rank')\n",
    "        #print(\"text1\",mainUrl,element.text)\n",
    "        print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "    browser.quit()\n",
    "# a=[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\"]\n",
    "def data_get():\n",
    "        #数据读取并改变\n",
    "    csv_data=pd.read_csv(\"x.txt\")\n",
    "    csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "    csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "\n",
    "    df_shujuxiazai=pd.read_csv(\"dxw.txt\")\n",
    "    df_shujuxiazai=df_shujuxiazai.loc[:, ~df_shujuxiazai.columns.str.contains('^Unnamed')].drop_duplicates() #2去掉Unnamed 并且去重\n",
    "    df_shujuxiazai['code']=df_shujuxiazai['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_shujuxiazai[[\"code\",\"dxw\"]],how=\"left\")\n",
    "\n",
    "    df_rq=pd.read_csv(\"renqicsv2txt.txt\")\n",
    "    df_rq['code']=df_rq['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_rq[[\"code\",\"renqipaiming\"]],how='inner',on='code')  \n",
    "    print(csv_data.info())\n",
    "    return csv_data\n",
    "csv_data=data_get()\n",
    "a=csv_data.code.tolist()\n",
    "for b in range(int(len(a)/10)):\n",
    "#     print(a[5*b:5*(b+1)])\n",
    "    t1 = Thread(target=process, args=(a[10*b:10*(b+1)],csv_data,1))\n",
    "    t1.start()\n",
    "    time.sleep(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pymongo\n",
    "myclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\n",
    "myclient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "失败了\n"
     ]
    }
   ],
   "source": [
    "mydb = myclient[\"runoobdb\"]\n",
    " \n",
    "mycol = mydb[\"sites\"]\n",
    "dblist = myclient.list_database_names()\n",
    "# dblist = myclient.database_names() \n",
    "if \"runoobdb\" in dblist:\n",
    "    print(\"数据库已存在！\")\n",
    "else:\n",
    "    print(\"失败了\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 50 entries, 0 to 49\n",
      "Data columns (total 11 columns):\n",
      "code            50 non-null object\n",
      "和昨天比例           50 non-null float64\n",
      "和MA120比例        50 non-null float64\n",
      "运行time          50 non-null object\n",
      "fc时间            50 non-null int64\n",
      "x1<35%          50 non-null float64\n",
      "实时价格            50 non-null float64\n",
      "zk              50 non-null float64\n",
      "zd              50 non-null float64\n",
      "dxw             14 non-null object\n",
      "renqipaiming    50 non-null int64\n",
      "dtypes: float64(6), int64(2), object(3)\n",
      "memory usage: 4.7+ KB\n",
      "None\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\ipykernel_launcher.py:28: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[ObjectId('5fbfb4d03bc0a37dc6b35f8b'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f8c'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f8d'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f8e'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f8f'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f90'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f91'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f92'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f93'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f94'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f95'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f96'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f97'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f98'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f99'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9a'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9b'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9c'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9d'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9e'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35f9f'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa0'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa1'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa2'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa3'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa4'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa5'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa6'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa7'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa8'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fa9'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35faa'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fab'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fac'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fad'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fae'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35faf'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb0'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb1'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb2'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb3'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb4'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb5'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb6'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb7'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb8'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fb9'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fba'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fbb'),\n",
       " ObjectId('5fbfb4d03bc0a37dc6b35fbc')]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pymongo import MongoClient\n",
    "import datetime\n",
    "import pandas as pd\n",
    "import json\n",
    "client=MongoClient(host=\"127.0.0.1\",port=27017)\n",
    "table=client['mongo']['gp']\n",
    "# table.drop()\n",
    "\n",
    "\n",
    "\n",
    "def data_get():\n",
    "        #数据读取并改变\n",
    "    csv_data=pd.read_csv(\"x.txt\")\n",
    "    csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "    csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "\n",
    "    df_shujuxiazai=pd.read_csv(\"dxw.txt\")\n",
    "    df_shujuxiazai=df_shujuxiazai.loc[:, ~df_shujuxiazai.columns.str.contains('^Unnamed')].drop_duplicates() #2去掉Unnamed 并且去重\n",
    "    df_shujuxiazai['code']=df_shujuxiazai['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_shujuxiazai[[\"code\",\"dxw\"]],how=\"left\")\n",
    "\n",
    "    df_rq=pd.read_csv(\"renqicsv2txt.txt\")\n",
    "    df_rq['code']=df_rq['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_rq[[\"code\",\"renqipaiming\"]],how='inner',on='code')  \n",
    "    print(csv_data.info())\n",
    "    return csv_data\n",
    "csv_data=data_get()\n",
    "table.insert(json.loads(csv_data.T.to_json()).values())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# dic_kecheng={\"Python\":\"1000\",\n",
    "#             \"Java\":\"2000\"}\n",
    "dic_kecheng={\"name\":[\"Python\",\"Java\"],\"Price\":[\"1000\",\"2000\"]}\n",
    "\n",
    "class kecheng():\n",
    "    def __init__(self,name,jiage):\n",
    "        self.name=name\n",
    "        self.Price=jiage\n",
    "class banji():\n",
    "    def __init__(self,name,kecheng):\n",
    "        self.name=name\n",
    "        self.kecheng=kecheng()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'str' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-42-794c1e8eec66>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mk1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkecheng\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdic_kecheng\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"name\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdic_kecheng\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"Price\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mb1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbanji\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"1班\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"Python\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m \u001b[0mb1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkecheng\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-41-c93c1453520f>\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, name, kecheng)\u001b[0m\n\u001b[0;32m     10\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mkecheng\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     11\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkecheng\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkecheng\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'str' object is not callable"
     ]
    }
   ],
   "source": [
    "k1=kecheng(dic_kecheng[\"name\"][0],dic_kecheng[\"Price\"][0])\n",
    "b1=banji(\"1班\",\"Python\")\n",
    "b1.kecheng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import datetime\n",
    "class School(object):\n",
    "    def __init__(self,name,addr,website):\n",
    "        self.name=name\n",
    "        self.addr=addr\n",
    "        self.website=website\n",
    "        self.balance=0\n",
    "        self.branches=[]\n",
    "        self.class_list=[]\n",
    "        self.staff_list=[]\n",
    "        print(\"创建了校区[%s],地址[%s]\"%(name,addr))\n",
    "    def count_str_num(self):\n",
    "        pass\n",
    "    def count_staff_num(self):\n",
    "        pass\n",
    "    def staff_enrollment(self,staff_obj):\n",
    "        self.staff_list.append(staff_obj)\n",
    "        print(\"[%s]入职新员工[%s],部门[%s]岗位[%s]\"%(self.name,staff_obj.name,staff_obj.position,staff_obj.dept))\n",
    "    def count_total_revenue(self):\n",
    "        print(\"------校区总收入--------\")\n",
    "        total_rev=self.balance\n",
    "        for b in self.branches:\n",
    "            print(b.name,b.balance)\n",
    "            total_rev+=b.balance\n",
    "        print(\"各校区总收入%s:\"%(total_rev))\n",
    "        \n",
    "    def count_class_list(self):\n",
    "        print(\"------各个校区--------\")\n",
    "        for i in self.branches:\n",
    "            print(i.name,i.class_list)\n",
    "    def pay_salary(self):\n",
    "        print(\"发7月工资了\")\n",
    "        for i in self.staff_list:\n",
    "            i.balance+=i.salary\n",
    "            self.balance-=i.salary\n",
    "            print(\"给%s 发了%s,他的余额%s\"%(i.name,i.salary,i.balance))\n",
    "        print(\"公司余额%s\"%(self.balance))\n",
    "            \n",
    "    def __repr__(self):\n",
    "        return self.name\n",
    "class BranchSchool(School):\n",
    "    def __init__(self,name,addr,website,headquarter_obj):\n",
    "        super().__init__(name,addr,website)\n",
    "        self.headquarter=headquarter_obj\n",
    "        self.headquarter.branches.append(self)\n",
    "\n",
    "class Course(object):\n",
    "    def __init__(self,name,price,outline):\n",
    "        self.name=name\n",
    "        self.price=price\n",
    "        self.outline=outline\n",
    "        print(\"创建了课程是[%s],学费[%s]\"%(name,price))\n",
    "class Class(object):\n",
    "    \"\"\"班级\"\"\"\n",
    "    def __init__(self,course_obj,semester,school_obj):\n",
    "        self.course_obj=course_obj\n",
    "        self.semester=semester\n",
    "        self.school_obj=school_obj\n",
    "        self.stu_list=[]\n",
    "        school_obj.class_list.append(self)\n",
    "        print(\"校区[%s] 创建班级[%s]-学期[%s]\"%(school_obj.name,course_obj.name,semester))\n",
    "        print(school_obj.name,course_obj.name,semester) \n",
    "    def stu_transfer(self,stu_obj,new_class_obj):\n",
    "        pass\n",
    "    def __str__(self):\n",
    "        return \"%s-%s-%s\"%(self.school_obj.name,self.course_obj.name,self.semester)  \n",
    "    def __repr__(self):\n",
    "        return \"%s-%s-%s\"%(self.school_obj.name,self.course_obj.name,self.semester)  \n",
    "\n",
    "    \n",
    "class Staff(object):\n",
    "    \"\"\"员工\"\"\"\n",
    "    def __init__(self,name,age,balance,salary,position,dept,school_obj):\n",
    "        self.name=name\n",
    "        self.age=age\n",
    "        self.balance=balance\n",
    "        self.salary=salary\n",
    "        self.position=position\n",
    "        self.dept=dept\n",
    "        self.school_obj=school_obj\n",
    "        school_obj.staff_enrollment(self)\n",
    "    def punch_card(self):\n",
    "        pass\n",
    "class Teacher(Staff):\n",
    "    def __init__(self,name,age,balance,salary,position,dept,school_obj,course_obj):\n",
    "        super().__init__(name,age,balance,salary,position,dept,school_obj)\n",
    "        self.course_obj=course_obj\n",
    "    def teach_class(self,class_obj,day):\n",
    "        print(\"老师[%s]正在班级[%s]上第[%s]天的课\"%(self.name,class_obj,day))\n",
    "        \n",
    "class Student(object):\n",
    "    def __init__(self,name,age,balance,class_obj):\n",
    "        self.name=name\n",
    "        self.age=age\n",
    "        self.balance=balance\n",
    "        self.class_obj=class_obj\n",
    "        #加入班级\n",
    "        class_obj.stu_list.append(self)\n",
    "        class_obj.school_obj.balance += class_obj.course_obj.price\n",
    "        self.balance-=class_obj.course_obj.price\n",
    "        \n",
    "        print(\"班级[%s]加入新学员[%s]缴费[%s]\"%(class_obj,self.name,class_obj.course_obj.price))\n",
    "    def punch_card(self):\n",
    "        print(\"%s:学院在班级[%s]上课\"%(datetime.datetime.now(),class_obj))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "创建了校区[IT教育],地址[海淀区]\n",
      "创建了校区[张江校区],地址[张江]\n",
      "创建了校区[虹桥校区],地址[上海虹桥火车站]\n",
      "创建了校区[虹桥校区],地址[上海虹桥火车站]\n",
      "创建了课程是[Python],学费[21800]\n",
      "创建了课程是[Linux],学费[19800]\n",
      "创建了课程是[Testing],学费[19800]\n",
      "创建了课程是[Go],学费[22800]\n",
      "校区[IT教育] 创建班级[Python]-学期[24]\n",
      "IT教育 Python 24\n",
      "校区[张江校区] 创建班级[Go]-学期[5]\n",
      "张江校区 Go 5\n",
      "[IT教育]入职新员工[lts],部门[CEO]岗位[总师办]\n",
      "[虹桥校区]入职新员工[Todd],部门[CEO]岗位[总师办]\n",
      "[虹桥校区]入职新员工[日天],部门[讲师]岗位[教学部]\n",
      "班级[IT教育-Python-24]加入新学员[春生]缴费[21800]\n",
      "班级[张江校区-Go-5]加入新学员[小强]缴费[22800]\n",
      "[张江校区, 虹桥校区, 虹桥校区]\n",
      "22800\n",
      "------校区总收入--------\n",
      "张江校区 22800\n",
      "虹桥校区 0\n",
      "虹桥校区 0\n",
      "各校区总收入44600:\n",
      "None\n",
      "------各个校区--------\n",
      "张江校区 [张江校区-Go-5]\n",
      "虹桥校区 []\n",
      "虹桥校区 []\n",
      "None\n",
      "发7月工资了\n",
      "给lts 发了4000,他的余额4000\n",
      "公司余额17800\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "#创建校区\n",
    "headquarter=School(\"IT教育\",\"海淀区\",\"www.baidu.com\")\n",
    "sh1_school=BranchSchool(\"张江校区\",\"张江\",\"www.baidu.com\",headquarter)\n",
    "sh2_school=BranchSchool(\"虹桥校区\",\"上海虹桥火车站\",\"www.baidu.com\",headquarter)\n",
    "sz1_school=BranchSchool(\"虹桥校区\",\"上海虹桥火车站\",\"www.baidu.com\",headquarter) \n",
    "#创建课程\n",
    "py_course=Course(\"Python\",21800,None)\n",
    "linux_course=Course(\"Linux\",19800,None)\n",
    "test_course=Course(\"Testing\",19800,None)\n",
    "go_course=Course(\"Go\",22800,None)\n",
    "#创建班级\n",
    "py_24=Class(py_course,24,headquarter)\n",
    "go_5=Class(go_course,5,sh1_school)\n",
    "# 创建员工/老师/学员\n",
    "s1=Staff(\"lts\",26,0,4000,\"CEO\",\"总师办\",headquarter)\n",
    "s2=Staff(\"Todd\",45,0,60000,\"CEO\",\"总师办\",sh2_school)\n",
    "t1=Teacher(\"日天\",28,0,30000,\"讲师\",\"教学部\",sz1_school,py_course)\n",
    "stu1=Student(\"春生\",22,50000,py_24)\n",
    "stu2=Student(\"小强\",28,38000,go_5)\n",
    "print(headquarter.branches)\n",
    "print(sh1_school.balance)\n",
    "print(headquarter.count_total_revenue())\n",
    "print(headquarter.count_class_list())\n",
    "# print(headquarter.staff_enrollment())\n",
    "print(headquarter.pay_salary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (<ipython-input-43-641b70ca4857>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-43-641b70ca4857>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    1.定模型，多少个类\u001b[0m\n\u001b[1;37m             ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "1.定模型，多少个类\n",
    "  1）找出关键名词\n",
    "    总部\n",
    "    分校 \n",
    "    学员\n",
    "    老师\n",
    "    员工\n",
    "    课程\n",
    "    班级\n",
    "2.定属性\n",
    "    总部    名称 地址 电话 网址 \n",
    "            财务账户 \n",
    "            员工列表\n",
    "            学院列表\n",
    "            发工资\n",
    "            开分校\n",
    "            招聘\n",
    "            \n",
    "    分校    继承总部\n",
    "            pass\n",
    "            \n",
    "             \n",
    "    学员    姓名 年龄 班级 余额\n",
    "            上学打卡\n",
    "            转学？？\n",
    "            交学费\n",
    "    \n",
    "    员工    姓名 职务 部门 工资\n",
    "            上班打卡\n",
    "                    \n",
    "    老师    继承员工\n",
    "             教学\n",
    "    \n",
    "    课程    名称 价格 大纲\n",
    "    \n",
    "    班级    课程\n",
    "            学期\n",
    "            学院列表\n",
    "            转学\n",
    "            退学\n",
    "            上课记录\n",
    "            考试记录\n",
    "             \n",
    "3.定关系\n",
    "     分校————总部\n",
    "     学员----班级\n",
    "        班级----课程\n",
    "        班级----校区\n",
    "        老师----班级\n",
    "        老师----员工\n",
    "        学员----老师\n",
    "        员工--校区\n",
    "        \n",
    "4.画出UML模型图 统一建模语言\n",
    "5.写代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 50 entries, 0 to 49\n",
      "Data columns (total 11 columns):\n",
      "code            50 non-null object\n",
      "和昨天比例           50 non-null float64\n",
      "和MA120比例        50 non-null float64\n",
      "运行time          50 non-null object\n",
      "fc时间            50 non-null int64\n",
      "x1<35%          50 non-null float64\n",
      "实时价格            50 non-null float64\n",
      "zk              50 non-null float64\n",
      "zd              50 non-null float64\n",
      "dxw             14 non-null object\n",
      "renqipaiming    50 non-null int64\n",
      "dtypes: float64(6), int64(2), object(3)\n",
      "memory usage: 4.7+ KB\n",
      "None\n",
      "300619 286 [nan] 702 True\n",
      "600206 737 [nan] 692 False\n",
      "603618 2992 [nan] 2608 False\n",
      "600268 1603 ['游资'] 2203 True\n",
      "300419 431 [nan] 475 True\n",
      "600868 954 [nan] 1770 True\n",
      "600995 1500 [nan] 2034 True\n",
      "002386 2232 [nan] 1151 False\n",
      "300025 3047 [nan] 1498 False\n",
      "002156 204 [nan] 351 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-27:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 141, in _new_conn\n",
      "    (self.host, self.port), self.timeout, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 83, in create_connection\n",
      "    raise err\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 73, in create_connection\n",
      "    sock.connect(sa)\n",
      "ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 601, in urlopen\n",
      "    chunked=chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 357, in _make_request\n",
      "    conn.request(method, url, **httplib_request_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1239, in request\n",
      "    self._send_request(method, url, body, headers, encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1285, in _send_request\n",
      "    self.endheaders(body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1234, in endheaders\n",
      "    self._send_output(message_body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1026, in _send_output\n",
      "    self.send(msg)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 964, in send\n",
      "    self.connect()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 166, in connect\n",
      "    conn = self._new_conn()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 150, in _new_conn\n",
      "    self, \"Failed to establish a new connection: %s\" % e)\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002384A29BA90>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-5-29a60a1e869c>\", line 26, in process\n",
      "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 76, in text\n",
      "    return self._execute(Command.GET_ELEMENT_TEXT)['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 633, in _execute\n",
      "    return self._parent.execute(command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 319, in execute\n",
      "    response = self.command_executor.execute(driver_command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 374, in execute\n",
      "    return self._request(command_info[0], url, body=data)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 397, in _request\n",
      "    resp = self._conn.request(method, url, body=body, headers=headers)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 66, in request\n",
      "    **urlopen_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 87, in request_encode_url\n",
      "    return self.urlopen(method, url, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\poolmanager.py\", line 321, in urlopen\n",
      "    response = conn.urlopen(method, u.request_uri, **kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 639, in urlopen\n",
      "    _stacktrace=sys.exc_info()[2])\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\retry.py\", line 388, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53175): Max retries exceeded with url: /session/9fe71a78c03e9b881671212b264bfe01/element/1c065aac-1587-42a3-9423-d1c7deb18c96/text (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002384A29BA90>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。',))\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "300506 2390 [nan] 1668 False\n",
      "300698 3426 ['游资'] 1432 False\n",
      "600838 3020 [nan] 2427 False\n",
      "300634 2863 ['游资'] 2120 False\n",
      "300460 1465 [nan] 1063 False\n",
      "000016 731 [nan] 748 True\n",
      "002402 978 ['机构'] 938 False\n",
      "600744 267 [nan] 925 True\n",
      "600726 1060 ['游资'] 2073 True\n",
      "300733 962 [nan] 2479 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-28:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 141, in _new_conn\n",
      "    (self.host, self.port), self.timeout, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 83, in create_connection\n",
      "    raise err\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 73, in create_connection\n",
      "    sock.connect(sa)\n",
      "ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 601, in urlopen\n",
      "    chunked=chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 357, in _make_request\n",
      "    conn.request(method, url, **httplib_request_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1239, in request\n",
      "    self._send_request(method, url, body, headers, encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1285, in _send_request\n",
      "    self.endheaders(body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1234, in endheaders\n",
      "    self._send_output(message_body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1026, in _send_output\n",
      "    self.send(msg)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 964, in send\n",
      "    self.connect()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 166, in connect\n",
      "    conn = self._new_conn()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 150, in _new_conn\n",
      "    self, \"Failed to establish a new connection: %s\" % e)\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002384A2910B8>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-5-29a60a1e869c>\", line 26, in process\n",
      "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 76, in text\n",
      "    return self._execute(Command.GET_ELEMENT_TEXT)['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 633, in _execute\n",
      "    return self._parent.execute(command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 319, in execute\n",
      "    response = self.command_executor.execute(driver_command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 374, in execute\n",
      "    return self._request(command_info[0], url, body=data)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 397, in _request\n",
      "    resp = self._conn.request(method, url, body=body, headers=headers)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 66, in request\n",
      "    **urlopen_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 87, in request_encode_url\n",
      "    return self.urlopen(method, url, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\poolmanager.py\", line 321, in urlopen\n",
      "    response = conn.urlopen(method, u.request_uri, **kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 639, in urlopen\n",
      "    _stacktrace=sys.exc_info()[2])\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\retry.py\", line 388, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53273): Max retries exceeded with url: /session/a77e72a31807cef41e0c9d6018d8a1e5/element/84f10c95-59d7-4023-84a4-78c2b08203b7/text (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002384A2910B8>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。',))\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "300001 517 [nan] 259 False\n",
      "603679 1581 [nan] 3507 True\n",
      "002232 1521 ['游资'] 783 False\n",
      "603700 2503 [nan] 1613 False\n",
      "002531 416 ['机构'] 899 True\n",
      "000591 361 [nan] 442 True\n",
      "002463 511 [nan] 478 False\n",
      "603232 2614 [nan] 647 False\n",
      "300234 3089 [nan] 2900 False\n",
      "300202 1809 ['游资'] 2073 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-29:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 141, in _new_conn\n",
      "    (self.host, self.port), self.timeout, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 83, in create_connection\n",
      "    raise err\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 73, in create_connection\n",
      "    sock.connect(sa)\n",
      "ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 601, in urlopen\n",
      "    chunked=chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 357, in _make_request\n",
      "    conn.request(method, url, **httplib_request_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1239, in request\n",
      "    self._send_request(method, url, body, headers, encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1285, in _send_request\n",
      "    self.endheaders(body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1234, in endheaders\n",
      "    self._send_output(message_body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1026, in _send_output\n",
      "    self.send(msg)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 964, in send\n",
      "    self.connect()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 166, in connect\n",
      "    conn = self._new_conn()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 150, in _new_conn\n",
      "    self, \"Failed to establish a new connection: %s\" % e)\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002384A291470>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-5-29a60a1e869c>\", line 26, in process\n",
      "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 76, in text\n",
      "    return self._execute(Command.GET_ELEMENT_TEXT)['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 633, in _execute\n",
      "    return self._parent.execute(command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 319, in execute\n",
      "    response = self.command_executor.execute(driver_command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 374, in execute\n",
      "    return self._request(command_info[0], url, body=data)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 397, in _request\n",
      "    resp = self._conn.request(method, url, body=body, headers=headers)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 66, in request\n",
      "    **urlopen_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 87, in request_encode_url\n",
      "    return self.urlopen(method, url, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\poolmanager.py\", line 321, in urlopen\n",
      "    response = conn.urlopen(method, u.request_uri, **kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 639, in urlopen\n",
      "    _stacktrace=sys.exc_info()[2])\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\retry.py\", line 388, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53374): Max retries exceeded with url: /session/65084b83c4ac66d20d4bcd966fadbfe3/element/9091bcc6-2f32-4399-a696-7a0374fb11b6/text (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002384A291470>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。',))\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "603330 2771 [nan] 3111 True\n",
      "000564 724 ['游资'] 858 True\n",
      "603915 2092 ['游资'] 1463 False\n",
      "300113 1683 ['机构'] 1534 False\n",
      "600318 1490 ['游资'] 123 False\n",
      "002288 69 [nan] 1182 True\n",
      "300105 2951 [nan] 3553 True\n",
      "600292 3585 [nan] 3797 True\n",
      "600396 1050 ['游资'] 2112 True\n",
      "300094 253 [nan] 2888 True\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-30:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 141, in _new_conn\n",
      "    (self.host, self.port), self.timeout, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 83, in create_connection\n",
      "    raise err\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 73, in create_connection\n",
      "    sock.connect(sa)\n",
      "ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 601, in urlopen\n",
      "    chunked=chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 357, in _make_request\n",
      "    conn.request(method, url, **httplib_request_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1239, in request\n",
      "    self._send_request(method, url, body, headers, encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1285, in _send_request\n",
      "    self.endheaders(body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1234, in endheaders\n",
      "    self._send_output(message_body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1026, in _send_output\n",
      "    self.send(msg)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 964, in send\n",
      "    self.connect()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 166, in connect\n",
      "    conn = self._new_conn()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 150, in _new_conn\n",
      "    self, \"Failed to establish a new connection: %s\" % e)\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002384A293B38>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-5-29a60a1e869c>\", line 26, in process\n",
      "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 76, in text\n",
      "    return self._execute(Command.GET_ELEMENT_TEXT)['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 633, in _execute\n",
      "    return self._parent.execute(command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 319, in execute\n",
      "    response = self.command_executor.execute(driver_command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 374, in execute\n",
      "    return self._request(command_info[0], url, body=data)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 397, in _request\n",
      "    resp = self._conn.request(method, url, body=body, headers=headers)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 66, in request\n",
      "    **urlopen_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 87, in request_encode_url\n",
      "    return self.urlopen(method, url, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\poolmanager.py\", line 321, in urlopen\n",
      "    response = conn.urlopen(method, u.request_uri, **kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 639, in urlopen\n",
      "    _stacktrace=sys.exc_info()[2])\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\retry.py\", line 388, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53437): Max retries exceeded with url: /session/fa43d5a6ba98c12bf613aed994bdb945/element/28fc0b29-620b-4edf-86e6-4b45052134f9/text (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002384A293B38>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。',))\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "300108 1645 [nan] 700 False\n",
      "300065 998 ['机构'] 2514 True\n",
      "300366 2333 [nan] 2708 True\n",
      "000700 1387 [nan] 934 False\n",
      "000613 2403 [nan] 3349 True\n",
      "002660 2528 [nan] 1910 False\n",
      "300527 1351 [nan] 1119 False\n",
      "600131 1246 [nan] 2316 True\n",
      "300342 1867 [nan] 1260 False\n",
      "300364 728 [nan] 926 True\n",
      "总用时： 143.9821834564209\n",
      "[<Thread(Thread-27, stopped 7748)>, <Thread(Thread-28, stopped 11756)>, <Thread(Thread-29, stopped 10916)>, <Thread(Thread-30, stopped 11044)>, <Thread(Thread-31, stopped 11828)>]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in thread Thread-31:\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 141, in _new_conn\n",
      "    (self.host, self.port), self.timeout, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 83, in create_connection\n",
      "    raise err\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\connection.py\", line 73, in create_connection\n",
      "    sock.connect(sa)\n",
      "ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 601, in urlopen\n",
      "    chunked=chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 357, in _make_request\n",
      "    conn.request(method, url, **httplib_request_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1239, in request\n",
      "    self._send_request(method, url, body, headers, encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1285, in _send_request\n",
      "    self.endheaders(body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1234, in endheaders\n",
      "    self._send_output(message_body, encode_chunked=encode_chunked)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 1026, in _send_output\n",
      "    self.send(msg)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\http\\client.py\", line 964, in send\n",
      "    self.connect()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 166, in connect\n",
      "    conn = self._new_conn()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connection.py\", line 150, in _new_conn\n",
      "    self, \"Failed to establish a new connection: %s\" % e)\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002384A2A0630>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 916, in _bootstrap_inner\n",
      "    self.run()\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\threading.py\", line 864, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "  File \"<ipython-input-5-29a60a1e869c>\", line 26, in process\n",
      "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 76, in text\n",
      "    return self._execute(Command.GET_ELEMENT_TEXT)['value']\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webelement.py\", line 633, in _execute\n",
      "    return self._parent.execute(command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 319, in execute\n",
      "    response = self.command_executor.execute(driver_command, params)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 374, in execute\n",
      "    return self._request(command_info[0], url, body=data)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py\", line 397, in _request\n",
      "    resp = self._conn.request(method, url, body=body, headers=headers)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 66, in request\n",
      "    **urlopen_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\request.py\", line 87, in request_encode_url\n",
      "    return self.urlopen(method, url, **extra_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\poolmanager.py\", line 321, in urlopen\n",
      "    response = conn.urlopen(method, u.request_uri, **kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 668, in urlopen\n",
      "    **response_kw)\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\connectionpool.py\", line 639, in urlopen\n",
      "    _stacktrace=sys.exc_info()[2])\n",
      "  File \"C:\\ProgramData\\Anaconda5.0\\lib\\site-packages\\urllib3\\util\\retry.py\", line 388, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53502): Max retries exceeded with url: /session/c2df942fc1002852f37b42aa56420582/element/60a44558-d67a-4b99-8236-1a9955dac448/text (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002384A2A0630>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝，无法连接。',))\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# coding=utf-8\n",
    "# --coding--=utf-8\n",
    "'''\n",
    "多线程抓取深圳证券交易所本所公告数据\n",
    "Author:西兰\n",
    "Date：2019-11-30\n",
    "'''\n",
    "\n",
    "from selenium import webdriver\n",
    "import time\n",
    "import csv\n",
    "from threading import Thread\n",
    "import pandas as pd\n",
    "import re\n",
    "def process(code_list,csv_data,num):\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.set_page_load_timeout(20)\n",
    "    for code in code_list:\n",
    "\n",
    "        mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "        browser.get(mainUrl)\n",
    "        element = browser.find_element_by_id('ad_rank')\n",
    "        #print(\"text1\",mainUrl,element.text)\n",
    "        print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "    browser.quit()\n",
    "    return (code,int(\"\".join(re.findall(r\"\\d\",element.text))))\n",
    "def process2(code_list,csv_data,num):\n",
    "    browser = webdriver.Chrome()\n",
    "    browser.set_page_load_timeout(20)\n",
    "    for code in code_list:\n",
    "\n",
    "        mainUrl = \"http://mguba.eastmoney.com/mguba/list/{}\".format(code)\n",
    "        browser.get(mainUrl)\n",
    "        element = browser.find_element_by_id('ad_rank')\n",
    "        #print(\"text1\",mainUrl,element.text)\n",
    "        print(code,int(\"\".join(re.findall(r\"\\d\",element.text))),csv_data.loc[csv_data.code==code].dxw.values,int(csv_data.loc[csv_data.code==code].renqipaiming.values),int(\"\".join(re.findall(r\"\\d\",element.text)))<int(csv_data.loc[csv_data.code==code].renqipaiming.values))\n",
    "    browser.quit()\n",
    "\n",
    "\n",
    "def data_get():\n",
    "        #数据读取并改变\n",
    "    csv_data=pd.read_csv(\"x.txt\")\n",
    "    csv_data['code']=csv_data ['code'].astype(str).str.zfill(6)                            #1补缺\n",
    "    csv_data=csv_data.loc[:, ~csv_data.columns.str.contains('^Unnamed')].drop_duplicates()\n",
    "\n",
    "    df_shujuxiazai=pd.read_csv(\"dxw.txt\")\n",
    "    df_shujuxiazai=df_shujuxiazai.loc[:, ~df_shujuxiazai.columns.str.contains('^Unnamed')].drop_duplicates() #2去掉Unnamed 并且去重\n",
    "    df_shujuxiazai['code']=df_shujuxiazai['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_shujuxiazai[[\"code\",\"dxw\"]],how=\"left\")\n",
    "\n",
    "    df_rq=pd.read_csv(\"renqicsv2txt.txt\")\n",
    "    df_rq['code']=df_rq['code'].astype(str).str.zfill(6) #int64--object\n",
    "    csv_data=pd.merge(csv_data,df_rq[[\"code\",\"renqipaiming\"]],how='inner',on='code')  \n",
    "    print(csv_data.info())\n",
    "    return csv_data\n",
    "\n",
    "def main():\n",
    "\t #开启4个进程，传入爬取的页码范围\n",
    "    thead_list = []\n",
    "    csv_data=data_get()\n",
    "\n",
    "    #选取\n",
    "    csv_li=csv_data.code.tolist()\n",
    "    for i in range(int(len(csv_li)/10)):\n",
    "    #     print(csv_li[10*i:10*(i+1)])\n",
    "        t1 = Thread(target=process, args=(csv_li[10*i:10*(i+1)],csv_data,1))\n",
    "        t1.start()\n",
    "        time.sleep(10) \n",
    "#         t2 = Thread(target=process2, args=(csv_data.code[10:20],1))\n",
    "#         t2.start()\n",
    "\n",
    "        thead_list.append(t1)\n",
    "#         thead_list.append(t2)\n",
    "\n",
    "        for t in thead_list:\n",
    "            t.join()\n",
    "    return thead_list\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    s = time.time()\n",
    "    thead_list=main()\n",
    "    e = time.time()\n",
    "    print('总用时：',e-s)\n",
    "    print(thead_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'北京北': 'VAP', '北京东': 'BOP', '北京': 'BJP', '北京南': 'VNP', '北京西': 'BXP', '广州南': 'IZQ', '重庆北': 'CUW', '重庆': 'CQW', '重庆南': 'CRW', '重庆西': 'CXW', '广州东': 'GGQ', '上海': 'SHH', '上海南': 'SNH', '上海虹桥': 'AOH', '上海西': 'SXH', '天津北': 'TBP', '天津': 'TJP', '天津南': 'TIP', '天津西': 'TXP', '香港西九龙': 'XJA', '长春': 'CCT', '长春南': 'CET', '长春西': 'CRT', '成都东': 'ICW', '成都南': 'CNW', '成都': 'CDW', '成都西': 'CMW', '长沙': 'CSQ', '长沙南': 'CWQ', '大明湖': 'JAK', '福州': 'FZS', '福州南': 'FYS', '贵阳': 'GIW', '广州': 'GZQ', '广州西': 'GXQ', '哈尔滨': 'HBB', '哈尔滨东': 'VBB', '哈尔滨西': 'VAB', '合肥': 'HFH', '呼和浩特东': 'NDC', '呼和浩特': 'HHC', '海口东': 'HMQ', '海口': 'VUQ', '杭州东': 'HGH', '杭州': 'HZH', '杭州南': 'XHH', '济南': 'JNK', '济  南': 'EEI', '济南西': 'JGK', '济  南西': 'EII', '昆明': 'KMM', '昆明西': 'KXM', '拉萨': 'LSO', '兰州东': 'LVJ', '兰州': 'LZJ', '兰州西': 'LAJ', '南昌': 'NCG', '南京': 'NJH', '南京南': 'NKH', '南宁': 'NNZ', '石家庄北': 'VVP', '石家庄': 'SJP', '蜀山东': 'HTH', '沈阳': 'SYT', '沈阳北': 'SBT', '沈阳东': 'SDT', '沈阳南': 'SOT', '太原北': 'TBV', '太原东': 'TDV', '太原': 'TYV', '武汉': 'WHN', '王家营西': 'KNM', '乌鲁木齐': 'WAR', '西安北': 'EAY', '西安': 'XAY', '西安南': 'CAY', '西宁': 'XNO', '银川': 'YIJ', '郑州': 'ZZF', '阿尔山': 'ART', '安康': 'AKY', '阿克苏': 'ASR', '阿里河': 'AHX', '阿拉山口': 'AKR', '安平': 'APT', '安庆': 'AQH', '安顺': 'ASW', '鞍山': 'AST', '安阳': 'AYF', '北安': 'BAB', '蚌埠': 'BBH', '白城': 'BCT', '北海': 'BHZ', '白河': 'BEL', '白涧': 'BAP', '宝鸡': 'BJY', '滨江': 'BJB', '博克图': 'BKX', '百色': 'BIZ', '白山市': 'HJL', '北台': 'BTT', '包头东': 'BDC', '包头': 'BTC', '北屯市': 'BXR', '本溪': 'BXT', '白云鄂博': 'BEC', '白银西': 'BXJ', '亳州': 'BZH', '赤壁': 'CBN', '常德': 'VGQ', '承德': 'CDP', '长甸': 'CDT', '赤峰南': 'CFD', '茶陵': 'CDG', '苍南': 'CEH', '昌平': 'CPP', '崇仁': 'CRG', '昌图': 'CTT', '长汀镇': 'CDB', '曹县': 'CXK', '楚雄南': 'COM', '陈相屯': 'CXT', '长治北': 'CBF', '池州': 'IYH', '长征': 'CZJ', '常州': 'CZH', '郴州': 'CZQ', '长治': 'CZF', '沧州': 'COP', '崇左': 'CZZ', '大安北': 'RNT', '大成': 'DCT', '丹东': 'DUT', '东方红': 'DFB', '东莞东': 'DMQ', '大虎山': 'DHD', '敦煌': 'DHJ', '敦化': 'DHL', '德惠': 'DHT', '东京城': 'DJB', '大涧': 'DFP', '都江堰': 'DDW', '大连北': 'DFT', '大理': 'DKM', '大连': 'DLT', '定南': 'DNG', '大庆': 'DZX', '东胜': 'DOC', '大石桥': 'DQT', '大同': 'DTV', '东营': 'DPK', '大杨树': 'DUX', '都匀': 'RYW', '邓州': 'DOF', '达州': 'RXW', '德州': 'DZP', '额济纳': 'EJC', '二连': 'RLC', '恩施': 'ESN', '福鼎': 'FES', '凤凰机场': 'FJQ', '风陵渡': 'FLV', '涪陵': 'FLW', '富拉尔基': 'FRX', '抚顺北': 'FET', '佛山': 'FSQ', '阜新南': 'FXD', '阜阳': 'FYH', '格尔木': 'GRO', '广汉': 'GHW', '古交': 'GJV', '桂林北': 'GBZ', '古莲': 'GRX', '桂林': 'GLZ', '固始': 'GXN', '广水': 'GSN', '干塘': 'GNJ', '广元': 'GYW', '广州北': 'GBQ', '赣州': 'GZG', '公主岭': 'GLT', '公主岭南': 'GBT', '淮安': 'AUH', '淮北': 'HRH', '鹤北': 'HMB', '淮滨': 'HVN', '河边': 'HBV', '潢川': 'KCN', '韩城': 'HCY', '邯郸': 'HDP', '横道河子': 'HDB', '鹤岗': 'HGB', '皇姑屯': 'HTT', '红果': 'HEM', '黑河': 'HJB', '怀化': 'HHQ', '汉口': 'HKN', '葫芦岛': 'HLD', '海拉尔': 'HRX', '霍林郭勒': 'HWD', '海伦': 'HLB', '侯马': 'HMV', '哈密': 'HMR', '淮南': 'HAH', '桦南': 'HNB', '海宁西': 'EUH', '鹤庆': 'HQM', '怀柔北': 'HBP', '怀柔': 'HRP', '黄石东': 'OSN', '华山': 'HSY', '黄山': 'HKH', '黄石': 'HSN', '衡水': 'HSP', '衡阳': 'HYQ', '菏泽': 'HIK', '贺州': 'HXZ', '汉中': 'HOY', '惠州': 'HCQ', '吉安': 'VAG', '集安': 'JAL', '江边村': 'JBG', '晋城': 'JCF', '金城江': 'JJZ', '景德镇': 'JCG', '嘉峰': 'JFF', '加格达奇': 'JGX', '井冈山': 'JGG', '蛟河': 'JHL', '金华南': 'RNH', '金华': 'JBH', '九江': 'JJG', '吉林': 'JLL', '荆门': 'JMN', '佳木斯': 'JMB', '济宁': 'JIK', '集宁南': 'JAC', '酒泉': 'JQJ', '江山': 'JUH', '吉首': 'JIQ', '九台': 'JTL', '镜铁山': 'JVJ', '鸡西': 'JXB', '绩溪县': 'JRH', '嘉峪关': 'JGJ', '江油': 'JFW', '蓟州北': 'JKP', '锦州': 'JZD', '金州': 'JZT', '库尔勒': 'KLR', '开封': 'KFF', '岢岚': 'KLV', '凯里': 'KLW', '喀什': 'KSR', '昆山南': 'KNH', '奎屯': 'KTR', '开原': 'KYT', '六安': 'UAH', '灵宝': 'LBF', '芦潮港': 'UCH', '隆昌': 'LCW', '陆川': 'LKZ', '利川': 'LCN', '潞城': 'UTP', '临川': 'LCG', '鹿道': 'LDL', '娄底': 'LDQ', '临汾': 'LFV', '良各庄': 'LGP', '临河': 'LHC', '漯河': 'LON', '绿化': 'LWJ', '隆化': 'UHP', '丽江': 'LHM', '临江': 'LQL', '龙井': 'LJL', '吕梁': 'LHV', '醴陵': 'LLG', '柳林南': 'LKV', '滦平': 'UPP', '六盘水': 'UMW', '灵丘': 'LVV', '旅顺': 'LST', '兰溪': 'LWH', '陇西': 'LXJ', '澧县': 'LEQ', '临西': 'UEP', '龙岩': 'LYS', '耒阳': 'LYQ', '洛阳': 'LYF', '连云港东': 'UKH', '洛阳东': 'LDF', '临沂': 'LVK', '洛阳龙门': 'LLF', '柳园': 'DHR', '凌源': 'LYD', '辽源': 'LYL', '立志': 'LZX', '柳州': 'LZZ', '辽中': 'LZD', '麻城': 'MCN', '免渡河': 'MDX', '牡丹江': 'MDB', '莫尔道嘎': 'MRX', '满归': 'MHX', '明光': 'MGH', '漠河': 'MVX', '茂名': 'MDQ', '茂名西': 'MMZ', '密山': 'MSB', '马三家': 'MJT', '麻尾': 'VAW', '绵阳': 'MYW', '梅州': 'MOQ', '满洲里': 'MLX', '宁波东': 'NVH', '宁波': 'NGH', '南岔': 'NCB', '南充': 'NCW', '南丹': 'NDZ', '南大庙': 'NMP', '南芬': 'NFT', '讷河': 'NHX', '嫩江': 'NGX', '内江': 'NJW', '南通': 'NUH', '南阳': 'NFF', '碾子山': 'NZX', '平顶山': 'PEN', '盘锦': 'PVD', '平凉': 'PIJ', '平凉南': 'POJ', '平泉': 'PQP', '坪石': 'PSQ', '萍乡': 'PXG', '凭祥': 'PXZ', '郫县西': 'PCW', '攀枝花': 'PRW', '蕲春': 'QRN', '青城山': 'QSW', '青岛': 'QDK', '清河城': 'QYP', '曲靖': 'QJM', '黔江': 'QNW', '前进镇': 'QEB', '齐齐哈尔': 'QHX', '七台河': 'QTB', '沁县': 'QVV', '泉州东': 'QRS', '泉州': 'QYS', '衢州': 'QEH', '融安': 'RAZ', '汝箕沟': 'RQJ', '瑞金': 'RJG', '日照': 'RZK', '双城堡': 'SCB', '绥芬河': 'SFB', '韶关东': 'SGQ', '山海关': 'SHD', '绥化': 'SHB', '三间房': 'SFX', '苏家屯': 'SXT', '舒兰': 'SLL', '神木南': 'OMY', '三门峡': 'SMF', '商南': 'ONY', '遂宁': 'NIW', '四平': 'SPT', '商丘': 'SQF', '上饶': 'SRG', '韶山': 'SSQ', '宿松': 'OAH', '汕头': 'OTQ', '邵武': 'SWS', '涉县': 'OEP', '三亚': 'SEQ', '邵阳': 'SYQ', '十堰': 'SNN', '三元区': 'SMS', '双鸭山': 'SSB', '松原': 'VYT', '宿州': 'OXH', '苏州': 'SZH', '深圳': 'SZQ', '随州': 'SZN', '朔州': 'SUV', '深圳西': 'OSQ', '塘豹': 'TBQ', '塔尔气': 'TVX', '潼关': 'TGY', '塘沽': 'TGP', '塔河': 'TXX', '通化': 'THL', '泰来': 'TLX', '吐鲁番': 'TFR', '通辽': 'TLD', '铁岭': 'TLT', '陶赖昭': 'TPT', '图们': 'TML', '铜仁': 'RDQ', '唐山北': 'FUP', '田师府': 'TFT', '泰山': 'TAK', '天水': 'TSJ', '唐山': 'TSP', '通远堡': 'TYT', '太阳升': 'TQT', '泰州': 'UTH', '通州西': 'TAP', '五常': 'WCB', '武昌': 'WCN', '瓦房店': 'WDT', '威海': 'WKK', '芜湖': 'WHH', '乌海西': 'WXC', '吴家屯': 'WJT', '乌鲁木齐南': 'WMR', '武隆': 'WLW', '乌兰浩特': 'WWT', '渭南': 'WNY', '威舍': 'WSM', '歪头山': 'WIT', '武威': 'WUJ', '武威南': 'WWJ', '无锡': 'WXH', '乌西': 'WXR', '乌伊岭': 'WPB', '武夷山': 'WAS', '万源': 'WYY', '万州': 'WYW', '梧州': 'WZZ', '温州': 'RZH', '温州南': 'VRH', '西昌': 'ECW', '许昌': 'XCF', '西昌南': 'ENW', '锡林浩特': 'XTC', '厦门北': 'XKS', '厦门': 'XMS', '厦门高崎': 'XBS', '宣威': 'XWM', '新乡': 'XXF', '信阳': 'XUN', '咸阳': 'XYY', '襄阳': 'XFN', '熊岳城': 'XYT', '新余': 'XUG', '徐州': 'XCH', '延安': 'YWY', '宜宾': 'YBW', '亚布力南': 'YWB', '叶柏寿': 'YBD', '宜昌东': 'HAN', '盐城': 'AFH', '运城': 'YNV', '伊春': 'YCB', '宜昌': 'YCN', '榆次': 'YCV', '杨村': 'YBP', '宜春西': 'YCG', '伊尔施': 'YET', '燕岗': 'YGW', '永济': 'YIV', '延吉': 'YJL', '营口': 'YKT', '牙克石': 'YKX', '阎良': 'YNY', '玉林': 'YLZ', '榆林': 'ALY', '亚龙湾': 'TWQ', '一面坡': 'YPB', '伊宁': 'YMR', '阳平关': 'YAY', '玉屏': 'YZW', '原平': 'YPV', '延庆': 'YNP', '阳泉曲': 'YYV', '玉泉': 'YQB', '阳泉': 'AQP', '营山': 'NUW', '玉山': 'YNG', '燕山': 'AOP', '榆树': 'YRT', '鹰潭': 'YTG', '烟台': 'YAK', '伊图里河': 'YEX', '玉田县': 'ATP', '义乌': 'YWH', '阳新': 'YON', '义县': 'YXD', '益阳': 'AEQ', '岳阳': 'YYQ', '崖州': 'YUQ', '扬州': 'YLH', '永州': 'AOQ', '淄博': 'ZBK', '镇城底': 'ZDV', '自贡': 'ZGW', '珠海': 'ZHQ', '珠海北': 'ZIQ', '湛江': 'ZJZ', '镇江': 'ZJH', '张家界': 'DIQ', '张家口': 'ZMP', '周口': 'ZKN', '扎兰屯': 'ZTX', '驻马店': 'ZDN', '肇庆': 'ZVQ', '周水子': 'ZIT', '昭通': 'ZDW', '中卫': 'ZWJ', '资阳': 'ZYW', '遵义西': 'ZIW', '资中': 'ZZW', '枣庄': 'ZEK', '株洲': 'ZZQ', '枣庄西': 'ZFK', '昂昂溪': 'AAX', '阿城': 'ACB', '安达': 'ADX', '安德': 'ARW', '安定': 'ADP', '安多': 'ADO', '安广': 'AGT', '敖汉': 'YED', '艾河': 'AHP', '安化': 'PKQ', '艾家村': 'AJJ', '安家': 'AJB', '阿金': 'AJD', '安靖': 'PYW', '阿克陶': 'AER', '安口窑': 'AYY', '敖力布告': 'ALD', '安龙': 'AUZ', '阿龙山': 'ASX', '安陆': 'ALN', '阿木尔': 'JTX', '阿南庄': 'AZM', '鞍山西': 'AXT', '安塘': 'ATV', '安亭北': 'ASH', '阿图什': 'ATR', '安图': 'ATL', '安溪': 'AXS', '博鳌': 'BWQ', '白壁关': 'BGV', '蚌埠南': 'BMH', '巴楚': 'BCR', '板城': 'BUP', '北戴河': 'BEP', '保定': 'BDP', '宝坻': 'BPP', '八达岭': 'ILP', '巴东': 'BNN', '宝丰': 'BFF', '柏果': 'BGM', '布海': 'BUT', '白河东': 'BIY', '宝华山': 'BWH', '白河县': 'BEY', '白芨沟': 'BJJ', '碧鸡关': 'BJM', '北滘': 'IBQ', '碧江': 'BLQ', '白鸡坡': 'BBM', '笔架山': 'BSB', '八角台': 'BTD', '保康': 'BKD', '白奎堡': 'BKB', '白狼': 'BAT', '百浪': 'BRZ', '博乐': 'BOR', '巴林': 'BLX', '宝林': 'BNB', '北流': 'BOZ', '勃利': 'BLB', '布列开': 'BLR', '宝龙山': 'BND', '百里峡': 'AAP', '八面城': 'BMD', '班猫箐': 'BNM', '八面通': 'BMB', '北马圈子': 'BRP', '北票南': 'RPD', '白旗': 'BQP', '宝泉岭': 'BQB', '白泉': 'BQL', '巴山': 'BAY', '白水江': 'BSY', '白沙坡': 'BPM', '白石山': 'BAL', '白水镇': 'BUM', '包头 东': 'FDC', '坂田': 'BTQ', '泊头': 'BZP', '北屯': 'BYP', '本溪湖': 'BHT', '博兴': 'BXK', '八仙筒': 'VXD', '白音察干': 'BYC', '背荫河': 'BYB', '北营': 'BIV', '巴彦高勒': 'BAC', '白音他拉': 'BID', '鲅鱼圈': 'BYT', '白银市': 'BNJ', '白音胡硕': 'BCD', '巴中': 'IEW', '霸州': 'RMP', '北宅': 'BVP', '赤壁北': 'CIN', '查布嘎': 'CBC', '长城': 'CEJ', '长冲': 'CCM', '承德东': 'CCP', '赤峰': 'CID', '嵯岗': 'CAX', '柴岗': 'CGT', '长葛': 'CEF', '柴沟堡': 'CGV', '城固': 'CGY', '陈官营': 'CAJ', '成高子': 'CZB', '草海': 'WBW', '柴河': 'CHB', '册亨': 'CHZ', '草河口': 'CKT', '崔黄口': 'CHP', '巢湖': 'CIH', '蔡家沟': 'CJT', '成吉思汗': 'CJX', '岔江': 'CAM', '蔡家坡': 'CJY', '昌乐': 'CLK', '超梁沟': 'CYP', '慈利': 'CUQ', '昌黎': 'CLP', '长岭子': 'CLT', '晨明': 'CMB', '长农': 'CNJ', '昌平北': 'VBP', '常平': 'DAQ', '长坡岭': 'CPM', '辰清': 'CQB', '楚山': 'CSB', '长寿': 'EFW', '蔡山': 'CON', '磁山': 'CSP', '苍石': 'CST', '草市': 'CSL', '察素齐': 'CSC', '长山屯': 'CVT', '长汀': 'CES', '朝天南': 'CTY', '昌图西': 'CPT', '春湾': 'CQQ', '磁县': 'CIP', '岑溪': 'CNZ', '辰溪': 'CXQ', '磁西': 'CRP', '长兴南': 'CFH', '磁窑': 'CYK', '春阳': 'CAL', '城阳': 'CEK', '创业村': 'CEX', '朝阳川': 'CYL', '朝阳地': 'CDD', '朝阳南': 'CYD', '长垣': 'CYF', '朝阳镇': 'CZL', '滁州北': 'CUH', '常州北': 'ESH', '滁州': 'CXH', '潮州': 'CKQ', '常庄': 'CVK', '曹子里': 'CFP', '车转湾': 'CWM', '郴州西': 'ICQ', '沧州西': 'CBP', '德安': 'DAG', '大安': 'RAT', '大板': 'DBC', '大坝': 'DBJ', '大巴': 'DBD', '电白': 'NWQ', '到保': 'RBT', '达坂城': 'DCR', '定边': 'DYJ', '东边井': 'DBB', '德伯斯': 'RDT', '打柴沟': 'DGJ', '德昌': 'DVW', '滴道': 'DDB', '大磴沟': 'DKJ', '刀尔登': 'DRD', '得耳布尔': 'DRX', '杜尔伯特': 'TKX', '东方': 'UFQ', '丹凤': 'DGY', '东丰': 'DIL', '都格': 'DMM', '大官屯': 'DTT', '大关': 'RGW', '东光': 'DGP', '东海': 'DHB', '大灰厂': 'DHP', '大红旗': 'DQD', '大禾塘': 'SOQ', '东海县': 'DQH', '德惠西': 'DXT', '达家沟': 'DJT', '东津': 'DKB', '杜家': 'DJL', '大口屯': 'DKP', '东来': 'RVD', '德令哈': 'DHO', '带岭': 'DLB', '大林': 'DLD', '达拉特旗': 'DIC', '独立屯': 'DTX', '豆罗': 'DLV', '达拉特西': 'DNC', '大连西': 'GZT', '东明村': 'DMD', '洞庙河': 'DEP', '东明县': 'DNF', '大拟': 'DNZ', '大平房': 'DPD', '大盘石': 'RPP', '大埔': 'DPI', '大堡': 'DVT', '大庆东': 'LFX', '大其拉哈': 'DQX', '道清': 'DML', '对青山': 'DQB', '德清西': 'MOH', '大庆西': 'RHX', '砀山': 'DKH', '独山': 'RWW', '东升': 'DRQ', '登沙河': 'DWT', '读书铺': 'DPM', '大石头': 'DSL', '东胜西': 'DYC', '大石寨': 'RZT', '东台': 'DBH', '定陶': 'DQK', '灯塔': 'DGT', '大田边': 'DBM', '东通化': 'DTL', '丹徒': 'RUH', '大屯': 'DNT', '东湾': 'DRJ', '大武口': 'DFJ', '低窝铺': 'DWJ', '大王滩': 'DZZ', '大湾子': 'DFM', '大兴沟': 'DXL', '大兴': 'DXX', '定西': 'DSJ', '东乡': 'DXG', '代县': 'DKV', '定襄': 'DXV', '甸心': 'DXM', '东戌': 'RXP', '东辛庄': 'DXD', '丹阳': 'DYH', '大雁': 'DYX', '德阳': 'DYW', '当阳': 'DYN', '丹阳北': 'EXH', '大英东': 'IAW', '东淤地': 'DBV', '大营': 'DYV', '定远': 'EWH', '岱岳': 'RYV', '大元': 'DYZ', '大营镇': 'DJP', '大营子': 'DZD', '大战场': 'DTJ', '德州东': 'DIP', '东至': 'DCH', '低庄': 'DVQ', '东镇': 'DNV', '道州': 'DFZ', '东庄': 'DZV', '兑镇': 'DWV', '定州': 'DXP', '豆庄': 'ROP', '大竹园': 'DZY', '大杖子': 'DAP', '豆张庄': 'RZP', '峨边': 'EBW', '二道沟门': 'RDP', '二道湾': 'RDX', '鄂尔多斯': 'EEC', '二龙': 'RLD', '二龙山屯': 'ELA', '峨眉': 'EMW', '二密河': 'RML', '恩平': 'PXQ', '二营': 'RYJ', '鄂州': 'ECN', '福安': 'FAS', '丰城': 'FCG', '丰城南': 'FNG', '肥东': 'FIH', '发耳': 'FEM', '富海': 'FHX', '福海': 'FHR', '凤凰城': 'FHT', '汾河': 'FEV', '奉化': 'FHH', '富锦': 'FIB', '范家屯': 'FTT', '福利区': 'FLJ', '福利屯': 'FTB', '丰乐镇': 'FZB', '阜南': 'FNH', '阜宁': 'AKH', '抚宁': 'FNP', '福清': 'FQS', '福泉': 'VMW', '丰水村': 'FSJ', '丰顺': 'FUQ', '繁峙': 'FSV', '抚顺': 'FST', '福山口': 'FKP', '扶绥': 'FSZ', '冯屯': 'FTX', '浮图峪': 'FYP', '富县东': 'FDY', '凤县': 'FXY', '费县': 'FXK', '富县': 'FEY', '肥西': 'FAH', '汾阳': 'FAV', '凤阳': 'FUH', '扶余北': 'FBT', '分宜': 'FYG', '富源': 'FYM', '扶余': 'FYT', '富裕': 'FYX', '抚州北': 'FBG', '凤州': 'FZY', '丰镇': 'FZC', '范镇': 'VZK', '广安': 'VJW', '固安': 'GFP', '高碑店': 'GBP', '沟帮子': 'GBD', '甘草店': 'GDJ', '谷城': 'GCN', '藁城': 'GEP', '高村': 'GCV', '古城镇': 'GZB', '广德': 'GRH', '贵定': 'GTW', '古东': 'GDV', '贵港': 'GGZ', '官高': 'GVP', '葛根庙': 'GGT', '干沟': 'GGL', '甘谷': 'GGJ', '高各庄': 'GGP', '甘河': 'GAX', '根河': 'GEX', '郭家店': 'GDT', '孤家子': 'GKT', '古浪': 'GLJ', '皋兰': 'GEJ', '高楼房': 'GFM', '归流河': 'GHT', '关林': 'GLF', '甘洛': 'VOW', '郭磊庄': 'GLP', '高密': 'GMK', '公庙子': 'GMC', '工农湖': 'GRT', '广宁寺南': 'GNT', '广南卫': 'GNM', '高平': 'GPF', '甘泉北': 'GEY', '共青城': 'GAG', '甘旗卡': 'GQD', '甘泉': 'GQY', '高桥镇': 'GZD', '灌水': 'GST', '孤山口': 'GSP', '果松': 'GSL', '高山子': 'GSD', '嘎什甸子': 'GXD', '高台': 'GTJ', '高滩': 'GAY', '官厅': 'GTP', '古田': 'GTS', '官厅西': 'KEP', '贵溪': 'GXG', '涡阳': 'GYH', '巩义': 'GXF', '高邑': 'GIP', '巩义南': 'GYF', '广元南': 'GAW', '固原': 'GUJ', '菇园': 'GYL', '公营子': 'GYD', '光泽': 'GZS', '固镇': 'GEH', '瓜州': 'GZJ', '古镇': 'GNQ', '高州': 'GSQ', '盖州': 'GXT', '虢镇': 'GZY', '官字井': 'GOT', '冠豸山': 'GSS', '盖州西': 'GAT', '海安': 'HIH', '淮安南': 'AMH', '红安': 'HWN', '红安西': 'VXN', '黄柏': 'HBL', '海北': 'HEB', '鹤壁': 'HAF', '会昌北': 'XEG', '华城': 'VCQ', '河唇': 'HCZ', '汉川': 'HCN', '海城': 'HCT', '合川': 'WKW', '黑冲滩': 'HCJ', '黄村': 'HCP', '海城西': 'HXT', '化德': 'HGC', '洪洞': 'HDV', '霍尔果斯': 'HFR', '横峰': 'HFG', '韩府湾': 'HXJ', '汉沽': 'HGP', '黄瓜园': 'HYM', '红光镇': 'IGW', '浑河': 'HHT', '红花沟': 'VHD', '黄花筒': 'HUD', '贺家店': 'HJJ', '和静': 'HJR', '获嘉': 'HJF', '河津': 'HJV', '红江': 'HFM', '黑井': 'HIM', '涵江': 'HJS', '华家': 'HJT', '杭锦后旗': 'HDC', '河间西': 'HXP', '花家庄': 'HJM', '河口南': 'HKJ', '黄口': 'KOH', '湖口': 'HKG', '呼兰': 'HUB', '葫芦岛北': 'HPD', '浩良河': 'HHB', '哈拉海': 'HIT', '鹤立': 'HOB', '桦林': 'HIB', '黄陵': 'ULY', '海林': 'HRB', '虎林': 'VLB', '寒岭': 'HAT', '和龙': 'HLL', '海龙': 'HIL', '哈拉苏': 'HAX', '呼鲁斯太': 'VTJ', '火连寨': 'HLT', '黄梅': 'VEH', '韩麻营': 'HYP', '黄泥河': 'HHL', '海宁': 'HNH', '怀宁': 'APH', '惠农': 'HMJ', '和平': 'VAQ', '花棚子': 'HZM', '花桥': 'VQH', '宏庆': 'HEY', '怀仁': 'HRV', '华容': 'HRN', '华山北': 'HDY', '黄松甸': 'HDL', '和什托洛盖': 'VSR', '红山': 'VSB', '汉寿': 'VSQ', '衡山': 'HSQ', '黑水': 'HOT', '惠山': 'VCH', '虎什哈': 'HHP', '红寺堡': 'HSJ', '虎石台': 'HUT', '海石湾': 'HSO', '衡山西': 'HEQ', '红砂岘': 'VSJ', '黑台': 'HQB', '桓台': 'VTK', '和田': 'VTR', '会同': 'VTQ', '海坨子': 'HZT', '黑旺': 'HWK', '海湾': 'RWH', '红星': 'VXB', '徽县': 'HYY', '红兴隆': 'VHB', '换新天': 'VTB', '红岘台': 'HTJ', '红彦': 'VIX', '海晏': 'HFO', '合阳': 'HAY', '衡阳东': 'HVQ', '华蓥': 'HUW', '汉阴': 'HQY', '黄羊滩': 'HGJ', '汉源': 'WHW', '河源': 'VIQ', '花园': 'HUN', '湟源': 'HNO', '黄羊镇': 'HYJ', '湖州': 'VZH', '化州': 'HZZ', '黄州': 'VON', '霍州': 'HZV', '惠州西': 'VXQ', '巨宝': 'JRT', '靖边': 'JIY', '金宝屯': 'JBD', '晋城北': 'JEF', '金昌': 'JCJ', '鄄城': 'JCK', '交城': 'JNV', '建昌': 'JFD', '峻德': 'JDB', '井店': 'JFP', '鸡东': 'JOB', '江都': 'UDH', '鸡冠山': 'JST', '金沟屯': 'VGP', '静海': 'JHP', '金河': 'JHX', '锦河': 'JHB', '精河': 'JHR', '精河南': 'JIR', '江华': 'JHZ', '建湖': 'AJH', '纪家沟': 'VJD', '晋江': 'JJS', '锦界': 'JEY', '姜家': 'JJB', '金坑': 'JKT', '芨岭': 'JLJ', '金马村': 'JMM', '江门东': 'JWQ', '角美': 'JES', '江门': 'JOQ', '莒南': 'JOK', '井南': 'JNP', '建瓯': 'JVS', '经棚': 'JPC', '江桥': 'JQX', '九三': 'SSX', '金山北': 'EGH', '嘉善': 'JSH', '京山': 'JCN', '建始': 'JRN', '稷山': 'JVV', '吉舒': 'JSL', '建设': 'JET', '甲山': 'JOP', '建三江': 'JIB', '嘉善南': 'EAH', '金山屯': 'JTB', '江所田': 'JOM', '景泰': 'JTJ', '九台南': 'JNL', '吉文': 'JWX', '进贤': 'JUG', '莒县': 'JKK', '嘉祥': 'JUK', '介休': 'JXV', '嘉兴': 'JXH', '井陉': 'JJP', '嘉兴南': 'EPH', '夹心子': 'JXT', '简阳': 'JYW', '姜堰': 'UEH', '建阳': 'JYS', '巨野': 'JYK', '揭阳南': 'JRQ', '江永': 'JYZ', '缙云': 'JYH', '靖远': 'JYJ', '江源': 'SZL', '济源': 'JYF', '靖远西': 'JXJ', '胶州北': 'JZK', '焦作东': 'WEF', '金寨': 'JZH', '蓟州': 'JIP', '靖州': 'JEQ', '荆州': 'JBN', '胶州': 'JXK', '晋州': 'JXP', '锦州南': 'JOD', '焦作': 'JOF', '旧庄窝': 'JVP', '金杖子': 'JYD', '开安': 'KAT', '库车': 'KCR', '康城': 'KCP', '库都尔': 'KDX', '宽甸': 'KDT', '克东': 'KOB', '昆都仑召': 'KDC', '开江': 'KAW', '康金井': 'KJB', '喀喇其': 'KQX', '开鲁': 'KLC', '克拉玛依': 'KHR', '开平南': 'PVQ', '口前': 'KQL', '昆山': 'KSH', '奎山': 'KAB', '克山': 'KSB', '康熙岭': 'KXZ', '昆阳': 'KAM', '克一河': 'KHX', '开原西': 'KXT', '康庄': 'KZP', '来宾': 'UBZ', '老边': 'LLT', '灵宝西': 'LPF', '洛川东': 'LRY', '龙川': 'LUQ', '乐昌': 'LCQ', '黎城': 'UCP', '聊城': 'UCK', '蓝村': 'LCK', '两当': 'LDY', '林东': 'LRC', '乐都': 'LDO', '梁底下': 'LDP', '六道河子': 'LVP', '鲁番': 'LVM', '廊坊': 'LJP', '落垡': 'LOP', '廊坊北': 'LFP', '老府': 'UFD', '兰岗': 'LNB', '龙骨甸': 'LGM', '芦沟': 'LOM', '龙沟': 'LGJ', '拉古': 'LGB', '临海': 'UFH', '拉哈': 'LHX', '凌海': 'JID', '林海': 'LXX', '柳河': 'LNL', '六合': 'KLH', '龙华': 'LHP', '滦河沿': 'UNP', '六合镇': 'LEX', '亮甲店': 'LRT', '刘家店': 'UDT', '刘家河': 'LVT', '连江': 'LKS', '庐江': 'UJH', '李家': 'LJB', '廉江': 'LJZ', '两家': 'UJT', '龙江': 'LJX', '罗江': 'LJW', '龙嘉': 'UJL', '莲江口': 'LHB', '蔺家楼': 'ULK', '李家坪': 'LIJ', '兰考': 'LKF', '林口': 'LKB', '路口铺': 'LKQ', '老莱': 'LAX', '拉林': 'LAB', '陆良': 'LRM', '临澧': 'LWQ', '兰棱': 'LLB', '龙里': 'LLW', '零陵': 'UWZ', '卢龙': 'UAP', '喇嘛甸': 'LMX', '里木店': 'LMB', '洛门': 'LMJ', '龙南': 'UNG', '梁平': 'UQW', '罗平': 'LPM', '落坡岭': 'LPP', '乐平市': 'LPG', '六盘山': 'UPJ', '临清': 'UQK', '龙泉寺': 'UQJ', '乐山北': 'UTW', '乐善村': 'LUM', '冷水江东': 'UDQ', '连山关': 'LGT', '流水沟': 'USP', '丽水': 'USH', '陵水': 'LIQ', '罗山': 'LRN', '鲁山': 'LAF', '梁山': 'LMK', '灵石': 'LSV', '露水河': 'LUL', '庐山': 'LSG', '林盛堡': 'LBT', '柳树屯': 'LSD', '龙山镇': 'LAS', '梨树镇': 'LSB', '李石寨': 'LET', '黎塘': 'LTZ', '轮台': 'LAR', '芦台': 'LTP', '龙塘坝': 'LBM', '濑湍': 'LVZ', '骆驼巷': 'LTJ', '李旺': 'VLJ', '莱芜东': 'LWK', '狼尾山': 'LRJ', '灵武': 'LNJ', '莱芜西': 'UXK', '滦县': 'UXP', '朗乡': 'LXB', '陇县': 'LXY', '临湘': 'LXQ', '林西': 'LXC', '芦溪': 'LUG', '良乡': 'LAP', '莱西南': 'LXK', '略阳': 'LYY', '莱阳': 'LYK', '辽阳': 'LYT', '凌源东': 'LDD', '临沂东': 'UYK', '连云港': 'UIH', '临颍': 'LNF', '老营': 'LXL', '龙游': 'LMH', '罗源': 'LVS', '涟源': 'LAQ', '涞源': 'LYP', '林源': 'LYX', '耒阳西': 'LPQ', '临泽': 'LEJ', '龙爪沟': 'LZT', '雷州': 'UAQ', '六枝': 'LIW', '龙镇': 'LZA', '鹿寨': 'LIZ', '来舟': 'LZS', '拉鲊': 'LEM', '兰州新区': 'LQJ', '马鞍山': 'MAH', '毛坝': 'MBY', '毛坝关': 'MGY', '麻城北': 'MBN', '渑池': 'MCF', '明城': 'MCL', '庙城': 'MAP', '渑池南': 'MNF', '茅草坪': 'KPM', '猛洞河': 'MUQ', '磨刀石': 'MOB', '弥渡': 'MDF', '帽儿山': 'MRB', '明港': 'MGN', '梅河口': 'MHL', '马皇': 'MHZ', '孟家岗': 'MGB', '美兰': 'MHQ', '汨罗东': 'MQQ', '马莲河': 'MHB', '麻柳': 'MLY', '茂林': 'MLD', '穆棱': 'MLB', '茅岭': 'MLZ', '庙岭': 'MLL', '马林': 'MID', '马龙': 'MGM', '木里图': 'MUD', '汨罗': 'MLQ', '玛纳斯湖': 'MNR', '冕宁': 'UGW', '沐滂': 'MPQ', '马桥河': 'MQB', '闽清': 'MQS', '民权': 'MQF', '明水河': 'MUT', '麻山': 'MAB', '眉山': 'MSW', '米沙子': 'MST', '茂舍祖': 'MOM', '马踏': 'PWQ', '美溪': 'MEB', '勉县': 'MVY', '麻阳': 'MVQ', '密云北': 'MUP', '米易': 'MMW', '墨玉': 'MUR', '麦园': 'MYS', '米脂': 'MEY', '庙庄': 'MZJ', '明珠': 'MFQ', '宁安': 'NAB', '农安': 'NAT', '南博山': 'NBK', '南仇': 'NCK', '南城司': 'NSP', '宁村': 'NCZ', '宁德': 'NES', '南观村': 'NGP', '南宫东': 'NFP', '南关岭': 'NLT', '宁国': 'NNH', '宁海': 'NHH', '南华北': 'NHS', '南河川': 'NHJ', '泥河子': 'NHD', '宁家': 'NVT', '南靖': 'NJS', '牛家': 'NJB', '能家': 'NJD', '南口': 'NKP', '南口前': 'NKT', '南朗': 'NNQ', '乃林': 'NLD', '尼勒克': 'NIR', '那罗': 'ULZ', '宁陵县': 'NLF', '奈曼': 'NMD', '宁明': 'NMZ', '南木': 'NMX', '那铺': 'NPZ', '南桥': 'NQD', '那曲': 'NQO', '暖泉': 'NQJ', '南台': 'NTT', '南头': 'NOQ', '宁武': 'NWV', '南湾子': 'NWP', '南翔北': 'NEH', '宁乡': 'NXQ', '内乡': 'NXF', '牛心台': 'NXT', '南峪': 'NUP', '娘子关': 'NIP', '南召': 'NAF', '南杂木': 'NZT', '蓬安': 'PAW', '平安': 'PAL', '平安驿': 'PNO', '磐安镇': 'PAJ', '平安镇': 'PZT', '蒲城东': 'PEY', '蒲城': 'PCY', '裴德': 'PDB', '偏店': 'PRP', '坡底下': 'PXJ', '瓢儿屯': 'PRT', '平房': 'PFB', '平岗': 'PGL', '平果': 'PGZ', '平关': 'PGM', '盘关': 'PAM', '徘徊北': 'PHP', '平河口': 'PHM', '平湖': 'PHQ', '盘锦北': 'PBD', '潘家店': 'PDP', '皮口南': 'PKT', '普兰店': 'PLT', '偏岭': 'PNT', '平山': 'PSB', '彭山': 'PSW', '皮山': 'PSR', '磐石': 'PSL', '平社': 'PSV', '彭水': 'PHW', '平台': 'PVT', '平田': 'PTM', '莆田': 'PTS', '葡萄菁': 'PTW', '普湾': 'PWT', '平旺': 'PWV', '平型关': 'PGV', '普雄': 'POW', '蓬溪': 'KZW', '郫县': 'PWW', '平阳': 'ARH', '平洋': 'PYX', '平遥': 'PYV', '彭阳': 'PYJ', '平邑': 'PIK', '平原堡': 'PPJ', '平原': 'PYK', '平峪': 'PYP', '平庄北': 'PZD', '彭泽': 'PZG', '邳州': 'PJH', '泡子': 'POD', '平庄南': 'PND', '乾安': 'QOT', '庆安': 'QAB', '迁安': 'QQP', '祁东北': 'QRQ', '七甸': 'QDM', '曲阜东': 'QAK', '庆丰': 'QFT', '奇峰塔': 'QVP', '曲阜': 'QFK', '琼海': 'QYQ', '秦皇岛': 'QTP', '千河': 'QUY', '清河': 'QIP', '清河门': 'QHD', '清华园': 'QHP', '全椒': 'INH', '渠旧': 'QJZ', '潜江': 'QJN', '秦家': 'QJB', '祁家堡': 'QBT', '清涧县': 'QNY', '秦家庄': 'QZV', '七里河': 'QLD', '秦岭': 'QLY', '渠黎': 'QLZ', '青龙': 'QIB', '青龙山': 'QGH', '祁门': 'QIH', '前磨头': 'QMP', '青山': 'QSB', '确山': 'QSN', '清水': 'QUJ', '前山': 'QXQ', '戚墅堰': 'QYH', '青田': 'QVH', '桥头': 'QAT', '青铜峡': 'QTJ', '前卫': 'QWD', '前苇塘': 'QWP', '渠县': 'QRW', '祁县': 'QXV', '青县': 'QXP', '桥西': 'QXJ', '清徐': 'QUV', '旗下营': 'QXC', '千阳': 'QOY', '泉阳': 'QYL', '沁阳': 'QYF', '祁阳北': 'QVQ', '七营': 'QYJ', '庆阳山': 'QSJ', '清远': 'QBQ', '清原': 'QYT', '钦州东': 'QDZ', '钦州': 'QRZ', '青州市': 'QZK', '瑞安': 'RAH', '瑞昌': 'RCG', '如皋': 'RBH', '容桂': 'RUQ', '任丘': 'RQP', '乳山': 'ROK', '融水': 'RSZ', '热水': 'RSD', '容县': 'RXZ', '饶阳': 'RVP', '汝阳': 'RYF', '绕阳河': 'RHD', '汝州': 'ROF', '石坝': 'OBJ', '上板城': 'SBP', '施秉': 'AQW', '上板城南': 'OBP', '世博园': 'ZWT', '双城北': 'SBB', '舒城': 'OCH', '商城': 'SWN', '莎车': 'SCR', '顺昌': 'SCS', '神池': 'SMV', '沙城': 'SCP', '石城': 'SCT', '山城镇': 'SCL', '山丹': 'SDJ', '绥德': 'ODY', '顺德': 'ORQ', '水洞': 'SIL', '商都': 'SXC', '十渡': 'SEP', '四道湾': 'OUD', '顺德学院': 'OJQ', '绅坊': 'OLH', '双丰': 'OFB', '四方台': 'STB', '水富': 'OTW', '三关口': 'OKJ', '桑根达来': 'OGC', '韶关': 'SNQ', '上高镇': 'SVK', '沙海': 'SED', '上杭': 'JBS', '蜀河': 'SHY', '松河': 'SBM', '沙河': 'SHP', '沙河口': 'SKT', '赛汗塔拉': 'SHC', '沙河市': 'VOP', '沙后所': 'SSD', '山河屯': 'SHL', '三河县': 'OXP', '四合永': 'OHD', '双河镇': 'SEL', '三汇镇': 'OZW', '石河子': 'SZR', '三合庄': 'SVP', '三家店': 'ODP', '水家湖': 'SQH', '松江河': 'SJL', '沈家河': 'OJJ', '尚家': 'SJB', '孙家': 'SUB', '沈家': 'OJB', '双吉': 'SML', '松江': 'SAH', '三江口': 'SKD', '司家岭': 'OLK', '松江南': 'IMH', '石景山南': 'SRP', '邵家堂': 'SJJ', '三江县': 'SOZ', '松江镇': 'OZL', '三家寨': 'SMM', '十家子': 'SJD', '深井子': 'SWT', '施家嘴': 'SHM', '什里店': 'OMP', '疏勒': 'SUR', '疏勒河': 'SHJ', '舍力虎': 'VLD', '石磷': 'SPB', '石林': 'SLM', '双辽': 'ZJD', '绥棱': 'SIB', '石岭': 'SOL', '石林南': 'LNM', '石龙': 'SLQ', '萨拉齐': 'SLC', '索伦': 'SNT', '商洛': 'OLY', '沙岭子': 'SLP', '石门县北': 'VFQ', '三门峡南': 'SCF', '三门县': 'OQH', '神木西': 'OUY', '三门峡西': 'SXF', '石门县': 'OMQ', '肃宁': 'SYP', '宋': 'SOB', '双牌': 'SBZ', '沙坪坝': 'CYW', '四平东': 'PPT', '遂平': 'SON', '沙坡头': 'SFJ', '沙桥': 'SQM', '商丘南': 'SPF', '水泉': 'SID', '石泉县': 'SXY', '石桥子': 'SQT', '石人城': 'SRB', '石人': 'SRL', '山市': 'SQB', '神树': 'SWB', '鄯善': 'SSR', '三水': 'SJQ', '泗水': 'OSK', '松树': 'SFT', '石山': 'SAD', '首山': 'SAT', '三十家': 'SRD', '三十里堡': 'SST', '双水镇': 'PQQ', '松树镇': 'SSL', '松桃': 'MZQ', '索图罕': 'SHX', '三堂集': 'SDH', '石头': 'OTB', '神头': 'SEV', '沙沱': 'SFM', '上万': 'SWP', '孙吴': 'SKB', '沙湾县': 'SXR', '歙县': 'OVH', '遂溪': 'SXZ', '沙县': 'SAS', '绍兴': 'SOH', '石岘': 'SXL', '上西铺': 'SXM', '石峡子': 'SXJ', '沭阳': 'FMH', '绥阳': 'SYB', '寿阳': 'SYV', '水洋': 'OYP', '三阳川': 'SYJ', '上腰墩': 'SPJ', '三营': 'OEJ', '顺义': 'SOP', '三义井': 'OYD', '三源浦': 'SYL', '上虞': 'BDH', '三原': 'SAY', '上园': 'SUD', '水源': 'OYJ', '桑园子': 'SAJ', '绥中北': 'SND', '苏州北': 'OHH', '宿州东': 'SRH', '深圳东': 'BJQ', '深州': 'OZP', '孙镇': 'OZY', '绥中': 'SZD', '尚志': 'SZB', '师庄': 'SNM', '松滋': 'SIN', '师宗': 'SEM', '苏州园区': 'KAH', '苏州新区': 'ITH', '泰安': 'TMK', '台安': 'TID', '通安驿': 'TAJ', '桐柏': 'TBF', '通北': 'TBB', '桐城': 'TTH', '汤池': 'TCX', '郯城': 'TZK', '铁厂': 'TCL', '桃村': 'TCK', '通道': 'TRQ', '田东': 'TDZ', '天岗': 'TGL', '土贵乌拉': 'TGC', '通沟': 'TOL', '太谷': 'TGV', '塔哈': 'THX', '棠海': 'THM', '唐河': 'THF', '泰和': 'THG', '太湖': 'TKH', '团结': 'TIX', '谭家井': 'TNJ', '陶家屯': 'TOT', '唐家湾': 'PDQ', '统军庄': 'TZP', '吐列毛杜': 'TMD', '图里河': 'TEX', '铜陵': 'TJH', '田林': 'TFZ', '亭亮': 'TIZ', '铁力': 'TLB', '铁岭西': 'PXT', '图们北': 'QSL', '天门': 'TMN', '天门南': 'TNN', '太姥山': 'TLS', '土牧尔台': 'TRC', '土门子': 'TCJ', '洮南': 'TVT', '潼南': 'TVW', '太平川': 'TIT', '太平镇': 'TEB', '图强': 'TQX', '台前': 'TTK', '天桥岭': 'TQL', '土桥子': 'TQJ', '汤山城': 'TCT', '桃山': 'TAB', '台山': 'PUQ', '塔石嘴': 'TIM', '通途': 'TUT', '汤旺河': 'THB', '同心': 'TXJ', '土溪': 'TSW', '桐乡': 'TCH', '田阳': 'TRZ', '天义': 'TND', '汤阴': 'TYF', '驼腰岭': 'TIL', '太阳山': 'TYJ', '通榆': 'KTT', '汤原': 'TYB', '塔崖驿': 'TYP', '滕州东': 'TEK', '台州': 'TZH', '天祝': 'TZJ', '滕州': 'TXK', '天镇': 'TZV', '桐子林': 'TEW', '天柱山': 'QWH', '武安': 'WAP', '文安': 'WBP', '王安镇': 'WVP', '吴堡': 'WUY', '旺苍': 'WEW', '五叉沟': 'WCT', '温春': 'WDB', '文昌': 'WEQ', '五大连池': 'WRB', '文登': 'WBK', '五道沟': 'WDL', '五道河': 'WHP', '文地': 'WNZ', '卫东': 'WVT', '武当山': 'WRN', '望都': 'WDP', '乌尔旗汗': 'WHX', '潍坊': 'WFK', '万发屯': 'WFB', '王府': 'WUT', '瓦房店西': 'WXT', '王岗': 'WGB', '武功': 'WGY', '湾沟': 'WGL', '吴官田': 'WGM', '乌海': 'WVC', '苇河': 'WHB', '卫辉': 'WHF', '吴家川': 'WCJ', '五家': 'WUB', '威箐': 'WAM', '午汲': 'WJP', '渭津': 'WJL', '王家湾': 'WJJ', '倭肯': 'WQB', '五棵树': 'WKT', '五龙背': 'WBT', '万乐': 'WEB', '瓦拉干': 'WVX', '温岭': 'VHH', '五莲': 'WLK', '乌拉特前旗': 'WQC', '卧里屯': 'WLX', '渭南北': 'WBY', '乌奴耳': 'WRX', '万宁': 'WNQ', '万年': 'WWG', '渭南南': 'WVY', '渭南镇': 'WNJ', '沃皮': 'WPT', '吴桥': 'WUP', '汪清': 'WQL', '武清': 'WWP', '武山': 'WSJ', '文水': 'WEV', '魏善庄': 'WSP', '王瞳': 'WTP', '五台山': 'WSV', '王团庄': 'WZJ', '五五': 'WVR', '武乡东': 'WVV', '无锡东': 'WGH', '卫星': 'WVB', '闻喜': 'WXV', '无锡新区': 'IFH', '武穴': 'WXN', '吴圩': 'WYZ', '王杨': 'WYB', '武义': 'RYH', '五营': 'WWB', '瓦窑田': 'WIM', '五原': 'WYC', '苇子沟': 'WZL', '韦庄': 'WZY', '五寨': 'WZV', '王兆屯': 'WZB', '微子镇': 'WQP', '魏杖子': 'WKD', '新安': 'EAM', '兴安': 'XAZ', '新安县': 'XAF', '新保安': 'XAP', '下板城': 'EBP', '西八里': 'XLP', '宣城': 'ECH', '兴城': 'XCD', '小村': 'XEM', '新绰源': 'XRX', '下城子': 'XCB', '新城子': 'XCT', '喜德': 'EDW', '小得江': 'EJM', '西大庙': 'XMP', '小东': 'XOD', '小董': 'XEZ', '香坊': 'XFB', '信丰': 'EFG', '襄汾': 'XFV', '息烽': 'XFW', '新干': 'EGG', '轩岗': 'XGV', '孝感': 'XGN', '西固城': 'XUJ', '兴国': 'EUG', '西固': 'XIJ', '夏官营': 'XGJ', '西岗子': 'NBB', '宣汉': 'XHY', '襄河': 'XXB', '新和': 'XIR', '宣和': 'XWJ', '斜河涧': 'EEP', '新华屯': 'XAX', '新华': 'XHB', '新会': 'EFQ', '新晃': 'XLQ', '新化': 'EHQ', '宣化': 'XHP', '兴和西': 'XEC', '下花园': 'XYP', '小河沿': 'XYD', '小河镇': 'EKY', '徐家店': 'HYK', '徐家': 'XJB', '峡江': 'EJG', '新绛': 'XJV', '辛集': 'ENP', '新江': 'XJM', '西街口': 'EKM', '许家屯': 'XJT', '许家台': 'XTJ', '谢家镇': 'XMT', '兴凯': 'EKB', '香兰': 'XNB', '小榄': 'EAQ', '兴隆店': 'XDD', '新乐': 'ELP', '新林': 'XPX', '小岭': 'XLB', '西林': 'XYB', '西柳': 'GCT', '新李': 'XLJ', '仙林': 'XPH', '新立屯': 'XLD', '兴隆县': 'EXP', '兴隆镇': 'XZB', '新立镇': 'XGT', '新民': 'XMD', '西麻山': 'XMB', '下马塘': 'XAT', '孝南': 'XNV', '咸宁北': 'XRN', '兴宁': 'ENQ', '咸宁': 'XNN', '犀浦东': 'XAW', '西平': 'XPN', '兴平': 'XPY', '新坪田': 'XPM', '霞浦': 'XOS', '溆浦': 'EPQ', '犀浦': 'XIW', '新青': 'XQB', '新邱': 'XQD', '兴泉堡': 'XQJ', '仙人桥': 'XRL', '小寺沟': 'ESP', '杏树': 'XSB', '浠水': 'XZN', '下社': 'XSV', '小市': 'XST', '徐水': 'XSP', '夏石': 'XIZ', '秀山': 'ETW', '小哨': 'XAM', '新松浦': 'XOB', '杏树屯': 'XDT', '许三湾': 'XSJ', '湘潭': 'XTQ', '邢台': 'XTP', '向塘': 'XTG', '仙桃西': 'XAN', '下台子': 'EIP', '徐闻': 'XJQ', '新窝铺': 'EPD', '修武': 'XWF', '新县': 'XSN', '息县': 'ENN', '西乡': 'XQY', '湘乡': 'XXQ', '西峡': 'XIF', '孝西': 'XOV', '小新街': 'XXM', '新兴县': 'XGQ', '西小召': 'XZC', '小西庄': 'XXP', '向阳': 'XDB', '旬阳': 'XUY', '旬阳北': 'XBY', '兴业': 'SNZ', '小雨谷': 'XHM', '新沂': 'VIH', '兴义': 'XRZ', '信宜': 'EEQ', '小月旧': 'XFM', '小扬气': 'XYX', '襄垣': 'EIF', '夏邑县': 'EJH', '祥云西': 'EXM', '新友谊': 'EYB', '新阳镇': 'XZJ', '徐州东': 'UUH', '新帐房': 'XZX', '新肇': 'XZT', '悬钟': 'XRP', '襄州': 'XWN', '忻州': 'XXV', '汐子': 'XZD', '西哲里木': 'XRD', '新杖子': 'ERP', '依安': 'YAX', '姚安': 'YAC', '永安': 'YAS', '永安乡': 'YNB', '亚布力': 'YBB', '元宝山': 'YUD', '羊草': 'YAB', '秧草地': 'YKM', '阳澄湖': 'AIH', '迎春': 'YYB', '叶城': 'YER', '盐池': 'YKJ', '砚川': 'YYY', '阳春': 'YQQ', '宜城': 'YIN', '应城': 'YHN', '禹城': 'YCK', '晏城': 'YEK', '阳岔': 'YAL', '阳城': 'YNF', '郓城': 'YPK', '雁翅': 'YAP', '云彩岭': 'ACP', '虞城县': 'IXH', '营城子': 'YCT', '英德': 'YDQ', '永登': 'YDJ', '永定': 'YGS', '尹地': 'YDM', '阳东': 'WLQ', '雁荡山': 'YGH', '于都': 'YDG', '园墩': 'YAJ', '英德西': 'IIQ', '永丰营': 'YYM', '杨岗': 'YRB', '阳高': 'YOV', '阳谷': 'YIK', '友好': 'YOB', '余杭': 'EVH', '沿河城': 'YHP', '岩会': 'AEP', '羊臼河': 'YHM', '永嘉': 'URH', '盐津': 'AEW', '阳江': 'WRQ', '余江': 'YHG', '燕郊': 'AJP', '营街': 'YAM', '姚家': 'YAT', '岳家井': 'YGJ', '一间堡': 'YJT', '英吉沙': 'YIR', '云居寺': 'AFP', '燕家庄': 'AZK', '永康': 'RFH', '营口东': 'YGT', '银浪': 'YJX', '永郎': 'YLW', '宜良北': 'YSM', '永乐店': 'YDY', '伊拉哈': 'YLX', '杨陵': 'YSY', '伊林': 'YLB', '杨林': 'YLM', '余粮堡': 'YLD', '杨柳青': 'YQP', '月亮田': 'YUM', '义马': 'YMF', '阳明堡': 'YVV', '玉门': 'YXJ', '云梦': 'YMN', '元谋': 'YMM', '一面山': 'YST', '沂南': 'YNK', '宜耐': 'YVM', '伊宁东': 'YNR', '营盘水': 'YZJ', '羊堡': 'ABM', '阳泉北': 'YPP', '乐清': 'UPH', '焉耆': 'YSR', '源迁': 'AQK', '姚千户屯': 'YQT', '阳曲': 'YQV', '榆树沟': 'YGP', '月山': 'YBF', '偃师': 'YSF', '颍上': 'YVH', '沂水': 'YUK', '榆社': 'YSV', '玉石': 'YSJ', '玉舍': 'AUM', '窑上': 'ASP', '元氏': 'YSP', '杨树岭': 'YAD', '野三坡': 'AIP', '榆树屯': 'YSX', '榆树台': 'YUT', '鹰手营子': 'YIP', '源潭': 'YTQ', '牙屯堡': 'YTZ', '烟筒山': 'YSL', '烟筒屯': 'YUX', '羊尾哨': 'YWM', '越西': 'YHW', '阳西': 'WMQ', '永修': 'ACG', '攸县': 'YOG', '玉溪西': 'YXM', '弋阳': 'YIG', '余姚': 'YYH', '酉阳': 'AFW', '岳阳东': 'YIQ', '阳邑': 'ARP', '鸭园': 'YYL', '鸳鸯镇': 'YYJ', '燕子砭': 'YZY', '宜州': 'YSZ', '仪征': 'UZH', '兖州': 'YZK', '迤资': 'YQM', '羊者窝': 'AEM', '杨杖子': 'YZD', '镇安': 'ZEY', '治安': 'ZAD', '招柏': 'ZBP', '张百湾': 'ZUP', '中川机场': 'ZJJ', '枝城': 'ZCN', '子长': 'ZHY', '诸城': 'ZQK', '邹城': 'ZIK', '赵城': 'ZCV', '章党': 'ZHT', '正定': 'ZDP', '肇东': 'ZDB', '照福铺': 'ZFM', '章古台': 'ZGD', '赵光': 'ZGB', '中和': 'ZHX', '中华门': 'VNH', '枝江北': 'ZIN', '钟家村': 'ZJY', '朱家沟': 'ZUB', '紫荆关': 'ZYP', '周家': 'ZOB', '诸暨': 'ZDH', '镇江南': 'ZEH', '周家屯': 'ZOD', '褚家湾': 'CWJ', '湛江西': 'ZWQ', '朱家窑': 'ZUJ', '张兰': 'ZLV', '镇赉': 'ZLT', '枣林': 'ZIV', '扎鲁特': 'ZLD', '扎赉诺尔西': 'ZXX', '樟木头': 'ZOQ', '中牟': 'ZGF', '中宁东': 'ZDJ', '中宁': 'VNJ', '中宁南': 'ZNJ', '镇平': 'ZPF', '漳平': 'ZPS', '泽普': 'ZPR', '枣强': 'ZVP', '张桥': 'ZQY', '章丘': 'ZTK', '朱日和': 'ZRC', '泽润里': 'ZLM', '中山北': 'ZGQ', '樟树东': 'ZOG', '柞水': 'ZSY', '中山': 'ZSQ', '樟树': 'ZSG', '珠斯花': 'ZHD', '钟山': 'ZSZ', '珠窝': 'ZOP', '张维屯': 'ZWB', '彰武': 'ZWD', '钟祥': 'ZTN', '资溪': 'ZXS', '棕溪': 'ZOY', '镇西': 'ZVT', '张辛': 'ZIP', '正镶白旗': 'ZXC', '紫阳': 'ZVY', '枣阳': 'ZYN', '竹园坝': 'ZAW', '张掖': 'ZYJ', '镇远': 'ZUW', '漳州东': 'GOS', '漳州': 'ZUS', '子洲': 'ZZY', '涿州': 'ZXP', '壮志': 'ZUX', '中寨': 'ZZM', '咋子': 'ZAL', '卓资山': 'ZZC', '株洲西': 'ZAQ', '郑州西': 'XPF', '阿巴嘎旗': 'AQC', '阿城北': 'ABB', '阿尔山北': 'ARX', '安江东': 'ADA', '安吉': 'AJU', '安匠': 'MJP', '阿克塞': 'AKJ', '阿勒泰': 'AUR', '安陆西': 'AXN', '安仁': 'ARG', '安顺西': 'ASE', '安图西': 'AXL', '安亭西': 'AXU', '安阳东': 'ADF', '博白': 'BBZ', '八步': 'BBE', '栟茶': 'FWH', '八达岭长城': 'VLP', '保定东': 'BMP', '博尔塔拉': 'BER', '八方山': 'FGQ', '白沟': 'FEP', '滨海': 'YKP', '滨海北': 'FCP', '滨海港': 'BGU', '滨海西': 'FHP', '毕节': 'BOE', '宝鸡南': 'BBY', '北京大兴': 'IPP', '北京朝阳': 'IFP', '北井子': 'BRT', '八里甸子': 'BLT', '白马井': 'BFQ', '北票': 'BPT', '宝清': 'BUB', '璧山': 'FZW', '白沙铺': 'BSN', '白水县': 'BGY', '板塘': 'NGQ', '白文东': 'BCV', '宾西北': 'BBB', '本溪新城': 'BVT', '步行街': 'BWW', '宾阳': 'UKZ', '白云北': 'BVE', '白云机场北': 'BBA', '白洋淀': 'FWP', '宝应': 'BAU', '百宜': 'FHW', '白音华南': 'BOD', '霸州北': 'VPP', '彬州东': 'BFY', '巴中东': 'BDE', '彬州': 'BXY', '滨州': 'BIK', '宾州': 'BZB', '亳州南': 'BNU', '霸州西': 'FOP', '长安': 'CAA', '长安西': 'CXA', '澄城': 'CUY', '承德县北': 'IYP', '成  都东': 'WEI', '承德南': 'IVP', '曹妃甸东': 'POP', '曹妃甸港': 'PGP', '城固北': 'CBY', '长葛北': 'CGF', '查干湖': 'VAT', '巢湖东': 'GUH', '从江': 'KNW', '蔡家崖': 'EBV', '茶卡': 'CVO', '长乐东': 'CIS', '长乐': 'CAS', '长临河': 'FVH', '长流': 'CLA', '长乐南': 'CVS', '茶陵南': 'CNG', '长宁': 'CNE', '常平东': 'FQQ', '常平南': 'FPQ', '长箐': 'CQE', '长庆桥': 'CQJ', '重  庆西': 'WWI', '长寿北': 'COW', '长寿湖': 'CSE', '常熟': 'CAU', '潮汕': 'CBQ', '常山': 'CSU', '长沙西': 'RXQ', '朝天': 'CTE', '长汀南': 'CNS', '长武': 'CWY', '长兴': 'CBH', '苍溪': 'CXE', '楚雄': 'CUM', '城西': 'CIA', '长阳': 'CYN', '潮阳': 'CNQ', '朝阳湖': 'CYE', '昌邑': 'CRK', '长治东': 'CUF', '陈庄': 'CZY', '崇州': 'CZE', '长治南': 'CAF', '城子坦': 'CWT', '东安东': 'DCZ', '德保': 'RBZ', '都昌': 'DCG', '东岔': 'DCJ', '东城南': 'IYQ', '东戴河': 'RDD', '丹东西': 'RWT', '东二道河': 'DRB', '大方': 'DFE', '大丰': 'KRQ', '大方南': 'DNE', '东港北': 'RGT', '东莞港': 'DGA', '大港南': 'DNU', '大孤山': 'RMT', '东莞': 'RTQ', '东莞西': 'WGQ', '东花园北': 'QBP', '鼎湖东': 'UWQ', '鼎湖山': 'NVQ', '道滘': 'RRQ', '垫江': 'DJE', '洞井': 'FWQ', '丹江口': 'DON', '董家口': 'DTK', '大苴': 'DIM', '洞口': 'DKA', '达连河': 'DCB', '大荔': 'DNY', '大朗镇': 'KOQ', '得莫利': 'DTB', '大青沟': 'DSD', '德清': 'DRH', '东胜东': 'RSC', '砀山南': 'PRH', '大石头南': 'DAL', '当涂东': 'OWH', '大同南': 'DMV', '大通西': 'DTO', '大旺': 'WWQ', '定西北': 'DNJ', '大兴机场': 'IWP', '德兴东': 'DDG', '德兴': 'DWG', '丹霞山': 'IRQ', '大阳': 'RET', '大冶北': 'DBN', '都匀东': 'KJW', '大邑': 'DEE', '东营南': 'DOK', '大余': 'DYG', '邓州东': 'DDF', '定州东': 'DOP', '端州': 'WZQ', '大足南': 'FQW', '额敏': 'EMR', '峨眉山': 'IXW', '阿房宫': 'EGY', '鄂州东': 'EFN', '防城港北': 'FBZ', '丰城东': 'FIG', '凤城东': 'FDT', '富川': 'FDZ', '方城': 'FNF', '繁昌西': 'PUH', '丰都': 'FUW', '扶沟南': 'FGF', '福海西': 'FHA', '涪陵北': 'FEW', '枫林': 'FLN', '阜宁东': 'FDU', '富宁': 'FNM', '阜宁南': 'FNU', '佛坪': 'FUY', '法启': 'FQE', '芙蓉南': 'KCQ', '丰顺东': 'FDA', '复盛': 'FAW', '抚松': 'FSL', '佛山西': 'FOQ', '福山镇': 'FZQ', '福田': 'NZQ', '凤台南': 'FTU', '费县北': 'FBK', '阜新': 'FOT', '富阳': 'FYU', '富源北': 'FBM', '抚远': 'FYB', '富蕴': 'FYR', '阜阳西': 'FXU', '抚州东': 'FDG', '抚州': 'FZG', '方正': 'FNB', '福州 南': 'FXS', '固安东': 'GQP', '高安': 'GCG', '广安南': 'VUW', '贵安': 'GAE', '高碑店东': 'GMP', '古北口': 'GKP', '谷城北': 'GBN', '古城东': 'GUU', '恭城': 'GCZ', '藁城南': 'GUP', '贵定北': 'FMW', '广德南': 'GNU', '葛店南': 'GNN', '贵定县': 'KIW', '广汉北': 'GVW', '高花': 'HGD', '个旧': 'JJM', '革居': 'GEM', '高楞': 'GLB', '关岭': 'GLE', '桂林西': 'GEZ', '高密北': 'GVK', '光明城': 'IMQ', '灌南': 'GIU', '广宁': 'FBQ', '广宁寺': 'GQT', '广南县': 'GXM', '高平东': 'GVF', '桂平': 'GAZ', '高坪': 'GGN', '广平': 'GPP', '弓棚子': 'GPT', '赶水东': 'GDE', '光山': 'GUN', '谷山': 'FFQ', '观沙岭': 'FKQ', '古田北': 'GBS', '广通北': 'GPM', '高台南': 'GAJ', '古田会址': 'STS', '赣县北': 'GIG', '高邮北': 'GEU', '贵  阳北': 'WNI', '贵阳北': 'KQW', '观音机场': 'GCU', '贵阳东': 'KEW', '高邮': 'GAU', '灌云': 'GOU', '赣榆': 'GYU', '高邑西': 'GNP', '赣州西': 'GOG', '淮安东': 'HAU', '惠安': 'HNS', '怀安': 'QAP', '惠安堡': 'KBJ', '淮北北': 'PLH', '鹤壁东': 'HFF', '花博山': 'KBT', '寒葱沟': 'HKB', '霍城': 'SER', '珲春': 'HUL', '花城街': 'HCA', '河东机场': 'HFJ', '横道河子东': 'KUX', '邯郸东': 'HPP', '海东': 'LVO', '惠东': 'KDQ', '哈达铺': 'HDJ', '花都': 'HAA', '洪洞西': 'HTV', '海东西': 'HDO', '哈尔滨北': 'HTB', '合肥北城': 'COH', '合肥南': 'ENH', '合肥 南': 'HAI', '黄冈': 'KGN', '黄冈东': 'KAN', '横沟桥东': 'HNN', '黄冈西': 'KXN', '洪河': 'HPB', '怀化南': 'KAQ', '黄河景区': 'HCF', '惠环': 'KHQ', '花湖': 'KHN', '后湖': 'IHN', '怀集': 'FAQ', '厚街': 'HJA', '河口北': 'HBM', '宏克力': 'OKB', '怀来': 'VQP', '海林北': 'KBX', '黄流': 'KLQ', '黄陵南': 'VLY', '虎门北': 'HBA', '虎门东': 'HDA', '鲘门': 'KMQ', '海门': 'HMU', '虎门': 'IUQ', '洪梅': 'HMA', '侯马西': 'HPV', '衡南': 'HNG', '淮南东': 'HOH', '淮南南': 'HNU', '合浦': 'HVZ', '横琴北': 'HOA', '霍邱': 'FBH', '横琴': 'HQA', '怀仁东': 'HFV', '华容东': 'HPN', '华容南': 'KRN', '怀柔南': 'IMP', '红寺堡北': 'HEJ', '黑山北': 'HQT', '黄山北': 'NYH', '黄石北': 'KSN', '衡水北': 'IHP', '贺胜桥东': 'HLN', '和硕': 'VUR', '含山南': 'HSU', '花山南': 'KNN', '黑山寺': 'HVP', '花山镇': 'HZA', '荷塘': 'KXQ', '黄桶北': 'HBE', '黄土店': 'HKP', '花土沟': 'HTO', '环县': 'KXJ', '合阳北': 'HTY', '海阳北': 'HEK', '槐荫': 'IYN', '鄠邑': 'KXY', '花园口': 'HYT', '淮阳南': 'HVF', '霍州东': 'HWV', '惠州南': 'KNQ', '建安': 'JUL', '吉安西': 'JIG', '晋城东': 'JGF', '泾川': 'JAJ', '碱厂': 'JUT', '景德镇北': 'JDG', '旌德': 'NSH', '建德': 'JDU', '尖峰': 'PFQ', '近海': 'JHD', '蛟河西': 'JOL', '军粮城北': 'JMP', '将乐': 'JLS', '贾鲁河': 'JLF', '九郎山': 'KJQ', '即墨北': 'JVK', '剑门关': 'JME', '佳木斯西': 'JUB', '建宁县北': 'JCS', '莒南北': 'VNK', '济南东': 'MDK', '江宁': 'JJH', '江宁西': 'OKH', '建瓯东': 'JZS', '建瓯西': 'JUS', '建平': 'JAD', '建桥': 'JQA', '酒泉南': 'JNJ', '句容西': 'JWH', '建水': 'JSM', '尖山': 'JPQ', '界首南': 'JKU', '界首市': 'JUN', '吉水西': 'JSG', '绩溪北': 'NRH', '介休东': 'JDV', '泾县': 'LOH', '靖西': 'JMZ', '郏县': 'JXF', '进贤南': 'JXG', '揭阳': 'JYA', '江油北': 'JBE', '揭阳机场': 'JUA', '简阳南': 'JOW', '嘉峪关南': 'JBJ', '金银潭': 'JTN', '靖宇': 'JYL', '金月湾': 'PYQ', '缙云西': 'PYH', '晋中': 'JZV', '景州': 'JEP', '焦作西': 'JIF', '库尔木依': 'VPR', '开封北': 'KBF', '开福寺': 'FLQ', '开化': 'KHU', '凯里南': 'QKW', '库伦': 'KLD', '昆明南': 'KOM', '葵潭': 'KTQ', '开阳': 'KVW', '昆玉': 'ESR', '喀左': 'KZT', '隆安东': 'IDZ', '冷坝': 'LBE', '来宾北': 'UCZ', '灵璧': 'GMH', '寮步': 'LTQ', '绿博园': 'LCF', '临沧': 'LXM', '隆昌北': 'NWW', '乐昌东': 'ILQ', '临城': 'UUP', '罗城': 'VCZ', '陵城': 'LGK', '老城镇': 'ACQ', '龙洞堡': 'FVW', '娄底南': 'UOQ', '乐东': 'UQQ', '离堆公园': 'INW', '娄烦': 'USV', '陆丰': 'LLQ', '来凤': 'LFA', '龙丰': 'KFQ', '禄丰南': 'LQM', '临汾西': 'LXV', '临高南': 'KGQ', '麓谷': 'BNQ', '滦河': 'UDP', '珞璜南': 'LNE', '隆回': 'LHA', '漯河西': 'LBN', '罗江东': 'IKW', '柳江': 'UQZ', '利津南': 'LNK', '庐江西': 'LUU', '厉家寨': 'UPK', '兰考南': 'LUF', '龙口市': 'UKK', '兰陵北': 'COK', '龙里北': 'KFW', '沥林北': 'KBQ', '醴陵东': 'UKQ', '芦庙': 'LMU', '陇南': 'INJ', '辽宁朝阳': 'VET', '六盘水东': 'LDE', '梁平南': 'LPE', '龙桥': 'LQU', '礼泉南': 'UNY', '龙泉市': 'LVU', '礼泉': 'LGY', '临泉': 'LOU', '龙山北': 'LBA', '灵石东': 'UDV', '乐山': 'IVW', '涟水': 'LIU', '龙市': 'LAG', '溧水': 'LDH', '娄山关南': 'LSE', '岚山西': 'UWK', '乐同': 'LEA', '龙塘镇': 'LVB', '灵武北': 'UWJ', '洛湾三江': 'KRW', '莱西': 'LBK', '岚县': 'UXV', '郎溪南': 'LXU', '溧阳': 'LEH', '临沂北': 'UMK', '临  沂北': 'III', '临邑': 'LUK', '柳园南': 'LNR', '龙游南': 'LYU', '鹿寨北': 'LSZ', '临淄北': 'UEK', '阆中': 'LZE', '临泽南': 'LDJ', '六枝南': 'LOE', '马鞍山东': 'OMH', '毛陈': 'MHN', '帽儿山西': 'MUB', '明港东': 'MDN', '民和南': 'MNO', '闵集': 'MJN', '米兰': 'MIR', '马兰': 'MLR', '民乐': 'MBJ', '弥勒': 'MLM', '玛纳斯': 'MSR', '牟平': 'MBK', '闽清北': 'MBS', '民权北': 'MIF', '眉山东': 'IUW', '名山': 'MSE', '蒙山': 'MOK', '庙山': 'MSN', '岷县': 'MXJ', '米易东': 'MDE', '门源': 'MYO', '暮云': 'KIQ', '密云': 'MYP', '蒙自北': 'MBM', '孟庄': 'MZF', '蒙自': 'MZM', '梅州西': 'MXA', '南部': 'NBE', '南曹': 'NEF', '南充北': 'NCE', '南城': 'NDG', '牛车河': 'NHA', '宁城': 'NCD', '南 昌': 'NOG', '南昌西': 'NXG', '宁东南': 'NDJ', '宁东': 'NOJ', '南芬北': 'NUT', '南丰': 'NFG', '南湖东': 'NDN', '牛河梁': 'LKT', '南华': 'NAM', '内江北': 'NKW', '南江': 'FIW', '南江口': 'NDQ', '奈林皋': 'NGT', '南陵': 'LLH', '牛栏山': 'NLP', '尼木': 'NMO', '南宁东': 'NFZ', '南宁西': 'NXZ', '南堡北': 'TLP', '南平市': 'NOS', '宁强南': 'NOY', '南通西': 'NXU', '泥溪': 'NIE', '宁县': 'AXJ', '南雄': 'NCQ', '南阳东': 'NOF', '纳雍': 'NYE', '南阳寨': 'NYF', '普安': 'PAN', '普安县': 'PUE', '屏边': 'PBM', '平坝南': 'PBE', '平昌': 'PCE', '普定': 'PGW', '平度': 'PNK', '平度西': 'PAK', '平顶山西': 'PDF', '蒲江': 'PJE', '皮口': 'PUT', '盘龙城': 'PNN', '蓬莱市': 'POK', '屏南': 'PNS', '普宁': 'PEQ', '平南南': 'PAZ', '平泉北': 'PBP', '彭山北': 'PPW', '蒲石': 'PSY', '屏山': 'PSE', '盘山': 'PUD', '坪上': 'PSK', '平潭': 'PIS', '萍乡北': 'PBG', '濮阳': 'PYF', '鄱阳': 'PYG', '平遥古城': 'PDV', '平原东': 'PUK', '邳州东': 'PIU', '平庄': 'PAD', '普者黑': 'PZM', '盘州': 'PAE', '彭州': 'PMW', '攀枝花南': 'PNE', '彭州南': 'PKW', '秦安': 'QGJ', '青白江东': 'QFW', '庆城': 'QHJ', '青川': 'QCE', '清城': 'QCA', '青岛北': 'QHK', '青  岛北': 'KAI', '千岛湖': 'QDU', '祁东': 'QMQ', '启东': 'QOU', '青堆': 'QET', '青岛西': 'QUK', '前锋': 'QFB', '清河门北': 'QBD', '齐河': 'QIK', '曲靖北': 'QBM', '綦江东': 'QDE', '曲江': 'QIM', '邛崃': 'QLE', '青莲': 'QEW', '齐齐哈尔南': 'QNB', '清水北': 'QEJ', '青神': 'QVW', '岐山': 'QAY', '庆盛': 'QSQ', '清水县': 'QIJ', '曲水县': 'QSO', '犍为': 'JWE', '祁县东': 'QGV', '乾县': 'QBY', '黔西': 'QXE', '旗下营南': 'QNC', '庆阳': 'QOJ', '祁阳': 'QWQ', '庆元': 'QYU', '青州市北': 'QOK', '乔庄东': 'QEP', '曲子': 'QJJ', '全州南': 'QNZ', '棋子湾': 'QZQ', '清镇西': 'QUE', '仁布': 'RUO', '荣昌北': 'RQW', '荣成': 'RCK', '瑞昌西': 'RXG', '如东': 'RIH', '如皋南': 'RNU', '榕江': 'RVW', '日喀则': 'RKO', '饶平': 'RVQ', '若羌': 'RQR', '日照西': 'KZK', '肃北': 'SBJ', '舒城东': 'SDU', '遂昌': 'SCU', '宋城路': 'SFF', '三道湖': 'SDL', '邵东': 'FIQ', '三都县': 'KKW', '胜芳': 'SUP', '双峰北': 'NFQ', '商河': 'SOK', '泗洪': 'GQH', '双河市': 'OHR', '四会': 'AHQ', '畲江北': 'SOA', '石家庄东': 'SXP', '三江南': 'SWZ', '沙井西': 'SJA', '三井子': 'OJT', '四棵树': 'SIR', '双流机场': 'IPW', '双龙湖': 'OHB', '狮岭': 'SLA', '石林西': 'SYM', '双流西': 'IQW', '胜利镇': 'OLB', '三明北': 'SHS', '三明': 'SVS', '嵩明': 'SVM', '树木岭': 'FMQ', '神木': 'HMY', '睢宁': 'SNU', '苏尼特左旗': 'ONC', '山坡东': 'SBN', '沈丘北': 'SKF', '商丘东': 'SIF', '沈丘': 'SQN', '宿迁': 'SQU', '石桥': 'SQE', '鄯善北': 'SMR', '狮山北': 'NSQ', '三水北': 'ARQ', '松山湖北': 'KUQ', '狮山': 'KSQ', '三水南': 'RNQ', '泗水南': 'ONK', '韶山南': 'INQ', '三穗': 'QHW', '石梯': 'STE', '汕尾': 'OGQ', '歙县北': 'NPH', '绍兴北': 'SLH', '绍兴东': 'SSH', '泗县': 'GPH', '始兴': 'IPQ', '松溪': 'SIS', '寿县': 'SOU', '随县': 'OVN', '泗阳': 'MPH', '双洋': 'SQS', '松阳': 'SUU', '三阳': 'SYU', '射阳': 'SAU', '双阳': 'OYT', '邵阳北': 'OVQ', '松原北': 'OCT', '十堰东': 'OUN', '山阴': 'SNV', '邵阳西': 'SXA', '顺义西': 'IKP', '沈阳西': 'OOT', '深圳机场北': 'SBA', '深圳北': 'IOQ', '深圳机场': 'SCA', '神州': 'SRQ', '桑植': 'SZA', '十字门': 'SIA', '尚志南': 'OZB', '随州南': 'ONN', '石嘴山': 'QQJ', '深圳坪山': 'IFQ', '石柱县': 'OSW', '台安南': 'TAD', '太仓': 'TCU', '桃村北': 'TOK', '桐城东': 'TOU', '铁厂沟': 'TJR', '塔城': 'TZR', '桐城南': 'TUU', '太仓南': 'TNU', '铁刹山': 'PST', '田东北': 'TBZ', '土地堂东': 'TTN', '太谷东': 'TEV', '铁干里克': 'VAR', '太谷西': 'TIV', '吐哈': 'THR', '通海': 'TAM', '太和北': 'JYN', '天河机场': 'TJN', '太和东': 'TDU', '天河街': 'TEN', '唐海南': 'IEP', '通化县': 'TXL', '同江': 'TJB', '托克托东': 'TVC', '铜陵北': 'KXH', '吐鲁番北': 'TAR', '桐庐': 'TLU', '图木舒克': 'TMR', '泰宁': 'TNS', '铜仁南': 'TNW', '甜水堡': 'TUJ', '天水南': 'TIJ', '通渭': 'TWJ', '田心东': 'KQQ', '汤逊湖': 'THN', '藤县': 'TAZ', '太原南': 'TNV', '桃源': 'TYA', '通远堡西': 'TST', '桐梓北': 'TBE', '太子城': 'IZP', '桐梓东': 'TDE', '通州': 'TOP', '万安县': 'WAG', '吴川': 'WAQ', '文登东': 'WGK', '武当山西': 'WWN', '潍坊北': 'WJK', '五府山': 'WFG', '威虎岭北': 'WBL', '芜湖北': 'WBU', '威海北': 'WHK', '芜湖南': 'RVH', '苇河西': 'WIB', '温江': 'WJE', '魏家泉': 'WJR', '乌兰察布': 'WPC', '五龙背东': 'WMT', '乌龙泉南': 'WFN', '乌兰木图': 'VLT', '望牛墩': 'WNA', '五女山': 'WET', '渭南西': 'WXY', '巍山': 'WOM', '武胜': 'WSE', '乌审旗': 'WGC', '乌苏': 'WSR', '五通': 'WTZ', '无为': 'IIH', '无为南': 'WWU', '瓦屋山': 'WAH', '威信': 'WXE', '武乡': 'WUV', '闻喜西': 'WOV', '武义北': 'WDH', '武夷山北': 'WBS', '婺源': 'WYG', '渭源': 'WEJ', '湾仔': 'WZA', '万州北': 'WZE', '湾仔北': 'WBA', '吴忠': 'WVJ', '武陟': 'WIF', '梧州南': 'WBZ', '湾沚南': 'WNU', '兴安北': 'XDZ', '雄安': 'IQP', '许昌北': 'EBF', '许昌东': 'XVF', '项城': 'ERN', '新都东': 'EWW', '西渡': 'XDA', '咸丰': 'XFA', '西丰': 'XFT', '先锋': 'NQQ', '湘府路': 'FVQ', '襄汾西': 'XTV', '孝感北': 'XJN', '新干东': 'XGG', '孝感东': 'GDN', '兴国西': 'XIG', '夏格庄': 'XZK', '下花园北': 'OKP', '兴和北': 'EBC', '宣化北': 'VJP', '西湖东': 'WDQ', '新化南': 'EJQ', '西华': 'EHF', '新晃西': 'EWQ', '新津': 'IRW', '小金口': 'NKQ', '辛集南': 'IJP', '新津南': 'ITW', '西来': 'XLE', '兴隆县西': 'IRP', '新民北': 'XOT', '厦 门': 'EMS', '咸宁东': 'XKN', '咸宁南': 'UNN', '溆浦南': 'EMQ', '西平西': 'EGQ', '响水县': 'XSU', '仙桃': 'VTN', '湘潭北': 'EDQ', '邢台东': 'EDP', '新塘南': 'NUQ', '兴文': 'XNE', '西乌旗': 'XWD', '修武西': 'EXF', '修文县': 'XWE', '萧县北': 'QSH', '新香坊北': 'RHB', '新乡东': 'EGF', '萧县': 'EOH', '岫岩': 'XXT', '新余北': 'XBG', '咸阳北': 'EBY', '西阳村': 'XQF', '信阳东': 'OYN', '襄垣东': 'EAF', '咸阳秦都': 'XOY', '襄阳东': 'EKN', '秀英': 'XYA', '新沂南': 'XYU', '仙游': 'XWS', '祥云': 'XQM', '新郑机场': 'EZF', '香樟路': 'FNQ', '忻州西': 'IXV', '雅安': 'YAE', '永安南': 'YQS', '盐边': 'YBE', '迎宾路': 'YFW', '亚布力西': 'YSB', '宜宾西': 'YXE', '永城北': 'RGH', '盐城北': 'AEH', '运城北': 'ABV', '永川东': 'WMW', '禹城东': 'YSK', '盐城大丰': 'YFU', '宜春': 'YEG', '岳池': 'AWW', '云东海': 'NAQ', '姚渡': 'AOJ', '云浮东': 'IXQ', '永福南': 'YBZ', '雨格': 'VTM', '阳高南': 'AGV', '洋河': 'GTH', '永济北': 'AJV', '延吉西': 'YXL', '英库勒': 'YLR', '永康南': 'QUH', '依兰': 'YEB', '运粮河': 'YEF', '尉犁': 'WRR', '炎陵': 'YAG', '鄢陵': 'YIF', '杨陵南': 'YEY', '羊马': 'YME', '一面坡北': 'YXB', '云梦东': 'YRN', '伊敏': 'YMX', '元谋西': 'AMM', '郁南': 'YKQ', '云南驿': 'ANM', '延平东': 'ADS', '延平': 'YPS', '银瓶': 'KPQ', '延平西': 'YWS', '原平西': 'IPV', '阳泉东': 'AYP', '雁栖湖': 'FGP', '杨桥': 'YQA', '阳曲西': 'IQV', '永仁': 'ARM', '颍上北': 'YBU', '永寿': 'ASY', '阳朔': 'YCZ', '云山': 'KZQ', '玉山南': 'YGG', '雁石南': 'YMS', '永寿西': 'AUY', '榆社西': 'AXV', '永泰': 'YTS', '银滩': 'CTQ', '鹰潭北': 'YKG', '依吞布拉克': 'YVR', '烟台南': 'YLK', '伊通': 'YTL', '烟台西': 'YTK', '尤溪': 'YXS', '云霄': 'YBS', '宜兴': 'YUH', '云县': 'AIM', '玉溪': 'AXM', '阳信': 'YVK', '应县': 'YZV', '攸县南': 'YXG', '洋县西': 'YXY', '义县西': 'YSD', '余姚北': 'CTH', '扬州东': 'YDU', '银盏': 'YZA', '禹州': 'YZF', '榆中': 'IZJ', '诏安': 'ZDS', '淄博北': 'ZRK', '正定机场': 'ZHP', '准东': 'ZER', '纸坊东': 'ZMN', '柘皋': 'ZGU', '准格尔': 'ZEC', '庄河北': 'ZUT', '政和': 'ZES', '珠海长隆': 'ZLA', '昭化': 'ZHW', '织金北': 'ZJE', '张家川': 'ZIJ', '张家港': 'ZAU', '织金': 'IZW', '芷江': 'ZPQ', '张家口南': 'IXP', '张家界西': 'JXA', '仲恺': 'KKQ', '周口东': 'ZKF', '曾口': 'ZKE', '珠琳': 'ZOM', '左岭': 'ZSN', '樟木头东': 'ZRQ', '驻马店西': 'ZLN', '周宁': 'ZNS', '邹平': 'ZLK', '漳浦': 'ZCS', '漳平西': 'ZXG', '章丘北': 'ZVK', '肇庆东': 'FCQ', '庄桥': 'ZQH', '昭山': 'KWQ', '钟山西': 'ZAZ', '朱砂古镇': 'ZSE', '中堂': 'ZTA', '支提山': 'ZIS', '中卫南': 'ZTJ', '漳县': 'ZXJ', '镇雄': 'ZXE', '资阳北': 'FYW', '遵义': 'ZYE', '遵义南': 'ZNE', '张掖西': 'ZEJ', '资中北': 'WZW', '枣庄东': 'ZNK', '卓资东': 'ZDC', '涿州东': 'ZAP', '郑州东': 'ZAF', '株洲南': 'KVQ'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "404\n"
     ]
    },
    {
     "ename": "JSONDecodeError",
     "evalue": "Expecting value: line 1 column 1 (char 0)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mJSONDecodeError\u001b[0m                           Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-11db410a34a5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m    120\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    121\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'__main__'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 122\u001b[1;33m     \u001b[0mspider_main\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m<ipython-input-1-11db410a34a5>\u001b[0m in \u001b[0;36mspider_main\u001b[1;34m()\u001b[0m\n\u001b[0;32m    116\u001b[0m     \u001b[1;31m# 主函数，程序运行入口\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    117\u001b[0m     \u001b[0mcity_id_dict\u001b[0m \u001b[1;33m=\u001b[0m  \u001b[0mcity_id\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 118\u001b[1;33m     \u001b[0msecretStr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetchepiaoinfo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcity_id_dict\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcity_id_dict\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    119\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0msecretStr\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    120\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-1-11db410a34a5>\u001b[0m in \u001b[0;36mgetchepiaoinfo\u001b[1;34m(city_id_dict)\u001b[0m\n\u001b[0;32m     97\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstatus_code\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     98\u001b[0m     \u001b[1;31m# 请求到的数据使用json来进行处理\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 99\u001b[1;33m     \u001b[0mjsdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'data'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'result'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    100\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    101\u001b[0m     \u001b[0mread_id\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda5.0\\lib\\json\\__init__.py\u001b[0m in \u001b[0;36mloads\u001b[1;34m(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[0;32m    352\u001b[0m             \u001b[0mparse_int\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mparse_float\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    353\u001b[0m             parse_constant is None and object_pairs_hook is None and not kw):\n\u001b[1;32m--> 354\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0m_default_decoder\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    355\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mcls\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    356\u001b[0m         \u001b[0mcls\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mJSONDecoder\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda5.0\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self, s, _w)\u001b[0m\n\u001b[0;32m    337\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    338\u001b[0m         \"\"\"\n\u001b[1;32m--> 339\u001b[1;33m         \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraw_decode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    340\u001b[0m         \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    341\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda5.0\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mraw_decode\u001b[1;34m(self, s, idx)\u001b[0m\n\u001b[0;32m    355\u001b[0m             \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscan_once\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    356\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 357\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mJSONDecodeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Expecting value\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    358\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)"
     ]
    }
   ],
   "source": [
    "# -- coding: utf-8 --\n",
    "# @Time : 2021/1/15 21:45\n",
    "# @Author : Los Angeles Clippers\n",
    "\n",
    "\n",
    "import requests\n",
    "import json\n",
    "import re\n",
    "\n",
    "def city_id():\n",
    "    \"\"\"\n",
    "    获取城市站台对应代号并保存到本地\n",
    "    :return: dict\n",
    "    \"\"\"\n",
    "    # 通过抓包可知城市代码信息为请求如下地址\n",
    "    url = \"https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9181\"\n",
    "    response = requests.get(url=url).text\n",
    "    # print(response)\n",
    "    # 通过正则表达式获取需要数据\n",
    "    find_city = re.findall(r'@.*?\\|(.*?)\\|', response)\n",
    "    find_city_id = re.findall(r'@.*?\\|.*?\\|(.*?)\\|', response)\n",
    "\n",
    "    city_id_dict = {}\n",
    "    for c, i in zip(find_city, find_city_id):\n",
    "        city_id_dict[c] = i\n",
    "    print(city_id_dict)\n",
    "    # 保存数据至本地\n",
    "    with open('city.txt', 'w', encoding='utf-8') as f:\n",
    "        f.write(str(city_id_dict))\n",
    "\n",
    "    return city_id_dict\n",
    "\n",
    "\n",
    "def decrypt(string):\n",
    "    \"\"\"\n",
    "    处理字符串\n",
    "    :param string:\n",
    "    :return:\n",
    "    \"\"\"\n",
    "    # 定义正则表达式提取规则\n",
    "    reg1 = re.compile('.*?\\|预订\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*')\n",
    "    reg2 = re.compile('.*?\\|.*?起售\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*')\n",
    "    reg3 = re.compile('.*?\\|.*?停运\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*')\n",
    "    reg4 = re.compile('.*?\\|.*?暂停发售\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|.*?\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|.*?\\|.*?\\|.*?\\|.*')\n",
    "    # 因网站存在三种状态的列车信息，所以使用try语句进行处理。\n",
    "\n",
    "    try:\n",
    "        result = re.findall(reg1,string)[0]\n",
    "    except IndexError as e:\n",
    "        try:\n",
    "            result = re.findall(reg2, string)[0]\n",
    "        except:\n",
    "            try:\n",
    "                result = re.findall(reg3, string)[0]\n",
    "            except:\n",
    "                result = re.findall(reg4, string)[0]\n",
    "    return result\n",
    "\n",
    "\n",
    "def getchepiaoinfo(city_id_dict):\n",
    "    \"\"\"\n",
    "    获取列车信息并保存至本地。\n",
    "    :param city_id_dict:\n",
    "    :return:\n",
    "    \"\"\"\n",
    "    # 通过抓包可知车次信息为请求如下地址得到\n",
    "    fs = '上海'\n",
    "    ts = '天津'\n",
    "    date = '2021-01-20'\n",
    "    url = \"https://kyfw.12306.cn/otn/leftTicket/queryT?\"\n",
    "    # 构造form表单\n",
    "    params = {\n",
    "        'leftTicketDTO.train_date': date,\n",
    "        'leftTicketDTO.from_station': city_id_dict[fs],\n",
    "        'leftTicketDTO.to_station': city_id_dict[ts],\n",
    "        'purpose_codes': 'ADULT',\n",
    "    }\n",
    "    headers = {\n",
    "        'Accept': '*/*',\n",
    "        'Accept-Encoding': 'gzip, deflate, br',\n",
    "        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',\n",
    "        'Cache-Control': 'no-cache',\n",
    "        'Connection': 'keep-alive',\n",
    "        'Host': 'kyfw.12306.cn',\n",
    "        'If-Modified-Since': '0',\n",
    "        'Pragma': 'no-cache',\n",
    "        'sec-ch-ua': '\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"',\n",
    "        'sec-ch-ua-mobile': '?0',\n",
    "        'Sec-Fetch-Dest': 'empty',\n",
    "        'Sec-Fetch-Mode': 'cors',\n",
    "        'Sec-Fetch-Site': 'same-origin',\n",
    "        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36',\n",
    "        'X-Requested-With': 'XMLHttpRequest',\n",
    "        'Cookie': '',\t# 自行添加\n",
    "    }\n",
    "    response = requests.get(url=url, params=params, headers=headers)\n",
    "    print(response.status_code)\n",
    "    # 请求到的数据使用json来进行处理\n",
    "    jsdata = json.loads(response.text)['data']['result']\n",
    "\n",
    "#     read_id = {}\n",
    "#     for k, v in city_id_dict.items():\n",
    "#         read_id[v] = k\n",
    "#     # 获取车次详情信息，并保存至本地\n",
    "#     for item in jsdata:\n",
    "#         # break\n",
    "#         result = list(decrypt(item))\n",
    "#         result[1] = fs\n",
    "#         result[2] = ts\n",
    "#         # 构建content列表，用于存放列车信息\n",
    "#         content = [result[0], read_id[item.split('|')[6]], read_id[item.split('|')[7]], result[3], result[4], result[5], result[-1], result[-2], result[-3],\n",
    "#         result[6], result[-10], result[8], result[-5], result[9], result[-4], result[-7], result[-6]]\n",
    "#         print(content)\n",
    "\n",
    "def spider_main():\n",
    "    # 主函数，程序运行入口\n",
    "    city_id_dict =  city_id()\n",
    "    secretStr = getchepiaoinfo(city_id_dict=city_id_dict)\n",
    "    return secretStr\n",
    "    \n",
    "if __name__ == '__main__':\n",
    "    spider_main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
